Skip to content

Commit e2fb38b

Browse files
authored
Rename parser functions with rbs_ prefix (#29)
1 parent 67b2fe1 commit e2fb38b

3 files changed

Lines changed: 192 additions & 192 deletions

File tree

ext/rbs_extension/main.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,19 +52,19 @@ static void declare_type_variables(rbs_parser_t *parser, VALUE variables, VALUE
5252
if (NIL_P(variables)) return; // Nothing to do.
5353

5454
if (!RB_TYPE_P(variables, T_ARRAY)) {
55-
free_parser(parser);
55+
rbs_parser_free(parser);
5656
rb_raise(rb_eTypeError,
5757
"wrong argument type %"PRIsVALUE" (must be an Array of Symbols or nil)",
5858
rb_obj_class(variables));
5959
}
6060

61-
parser_push_typevar_table(parser, true);
61+
rbs_parser_push_typevar_table(parser, true);
6262

6363
for (long i = 0; i < rb_array_len(variables); i++) {
6464
VALUE symbol = rb_ary_entry(variables, i);
6565

6666
if (!RB_TYPE_P(symbol, T_SYMBOL)) {
67-
free_parser(parser);
67+
rbs_parser_free(parser);
6868
rb_raise(rb_eTypeError,
6969
"Type variables Array contains invalid value %"PRIsVALUE" of type %"PRIsVALUE" (must be an Array of Symbols or nil)",
7070
rb_inspect(symbol), rb_obj_class(symbol));
@@ -78,7 +78,7 @@ static void declare_type_variables(rbs_parser_t *parser, VALUE variables, VALUE
7878
RSTRING_LEN(name_str)
7979
);
8080

81-
if (!parser_insert_typevar(parser, id)) {
81+
if (!rbs_parser_insert_typevar(parser, id)) {
8282
raise_error(parser->error, buffer);
8383
}
8484
}
@@ -92,7 +92,7 @@ struct parse_type_arg {
9292
};
9393

9494
static VALUE ensure_free_parser(VALUE parser) {
95-
free_parser((rbs_parser_t *)parser);
95+
rbs_parser_free((rbs_parser_t *)parser);
9696
return Qnil;
9797
}
9898

@@ -105,14 +105,14 @@ static VALUE parse_type_try(VALUE a) {
105105
}
106106

107107
rbs_node_t *type;
108-
parse_type(parser, &type);
108+
rbs_parse_type(parser, &type);
109109

110110
raise_error_if_any(parser, arg->buffer);
111111

112112
if (RB_TEST(arg->require_eof)) {
113-
parser_advance(parser);
113+
rbs_parser_advance(parser);
114114
if (parser->current_token.type != pEOF) {
115-
set_error(parser, parser->current_token, true, "expected a token `%s`", rbs_token_type_str(pEOF));
115+
rbs_parser_set_error(parser, parser->current_token, true, "expected a token `%s`", rbs_token_type_str(pEOF));
116116
raise_error(parser->error, arg->buffer);
117117
}
118118
}
@@ -136,7 +136,7 @@ static lexstate *alloc_lexer_from_buffer(rbs_allocator_t *allocator, VALUE strin
136136

137137
const char *encoding_name = rb_enc_name(encoding);
138138

139-
return alloc_lexer(
139+
return rbs_lexer_new(
140140
allocator,
141141
rbs_string_from_ruby_string(string),
142142
rbs_encoding_find((const uint8_t *) encoding_name, (const uint8_t *) (encoding_name + strlen(encoding_name))),
@@ -156,7 +156,7 @@ static rbs_parser_t *alloc_parser_from_buffer(VALUE buffer, int start_pos, int e
156156
rb_encoding *encoding = rb_enc_get(string);
157157
const char *encoding_name = rb_enc_name(encoding);
158158

159-
return alloc_parser(
159+
return rbs_parser_new(
160160
rbs_string_from_ruby_string(string),
161161
rbs_encoding_find((const uint8_t *) encoding_name,
162162
(const uint8_t *) (encoding_name + strlen(encoding_name))),
@@ -195,14 +195,14 @@ static VALUE parse_method_type_try(VALUE a) {
195195
}
196196

197197
rbs_methodtype_t *method_type = NULL;
198-
parse_method_type(parser, &method_type);
198+
rbs_parse_method_type(parser, &method_type);
199199

200200
raise_error_if_any(parser, arg->buffer);
201201

202202
if (RB_TEST(arg->require_eof)) {
203-
parser_advance(parser);
203+
rbs_parser_advance(parser);
204204
if (parser->current_token.type != pEOF) {
205-
set_error(parser, parser->current_token, true, "expected a token `%s`", rbs_token_type_str(pEOF));
205+
rbs_parser_set_error(parser, parser->current_token, true, "expected a token `%s`", rbs_token_type_str(pEOF));
206206
raise_error(parser->error, arg->buffer);
207207
}
208208
}
@@ -244,7 +244,7 @@ static VALUE parse_signature_try(VALUE a) {
244244
rbs_parser_t *parser = arg->parser;
245245

246246
rbs_signature_t *signature = NULL;
247-
parse_signature(parser, &signature);
247+
rbs_parse_signature(parser, &signature);
248248

249249
raise_error_if_any(parser, arg->buffer);
250250

include/rbs/parser.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,39 +75,39 @@ typedef struct {
7575
* end
7676
* ```
7777
* */
78-
void parser_push_typevar_table(rbs_parser_t *parser, bool reset);
78+
void rbs_parser_push_typevar_table(rbs_parser_t *parser, bool reset);
7979

8080
/**
8181
* Insert new type variable into the latest table.
8282
* */
83-
NODISCARD bool parser_insert_typevar(rbs_parser_t *parser, rbs_constant_id_t id);
83+
NODISCARD bool rbs_parser_insert_typevar(rbs_parser_t *parser, rbs_constant_id_t id);
8484

8585
/**
8686
* Allocate new lexstate object.
8787
*
8888
* ```
8989
* VALUE string = rb_funcall(buffer, rb_intern("content"), 0);
90-
* alloc_lexer(string, 0, 31) // New lexstate with buffer content
90+
* rbs_lexer_new(string, 0, 31) // New lexstate with buffer content
9191
* ```
9292
* */
93-
lexstate *alloc_lexer(rbs_allocator_t *, rbs_string_t string, const rbs_encoding_t *encoding, int start_pos, int end_pos);
93+
lexstate *rbs_lexer_new(rbs_allocator_t *, rbs_string_t string, const rbs_encoding_t *encoding, int start_pos, int end_pos);
9494

9595
/**
9696
* Allocate new rbs_parser_t object.
9797
*
9898
* ```
99-
* alloc_parser(buffer, string, encoding, 0, 1);
99+
* rbs_parser_new(buffer, string, encoding, 0, 1);
100100
* ```
101101
* */
102-
rbs_parser_t *alloc_parser(rbs_string_t string, const rbs_encoding_t *encoding, int start_pos, int end_pos);
103-
void free_parser(rbs_parser_t *parser);
102+
rbs_parser_t *rbs_parser_new(rbs_string_t string, const rbs_encoding_t *encoding, int start_pos, int end_pos);
103+
void rbs_parser_free(rbs_parser_t *parser);
104104

105105
/**
106106
* Advance one token.
107107
* */
108-
void parser_advance(rbs_parser_t *parser);
108+
void rbs_parser_advance(rbs_parser_t *parser);
109109

110-
void print_parser(rbs_parser_t *parser);
110+
void rbs_parser_print(rbs_parser_t *parser);
111111

112112
/**
113113
* Returns a RBS::Comment object associated with an subject at `subject_line`.
@@ -122,12 +122,12 @@ void print_parser(rbs_parser_t *parser);
122122
* end
123123
* ```
124124
* */
125-
rbs_ast_comment_t *get_comment(rbs_parser_t *parser, int subject_line);
125+
rbs_ast_comment_t *rbs_parser_get_comment(rbs_parser_t *parser, int subject_line);
126126

127-
void set_error(rbs_parser_t *parser, rbs_token_t tok, bool syntax_error, const char *fmt, ...) RBS_ATTRIBUTE_FORMAT(4, 5);
127+
void rbs_parser_set_error(rbs_parser_t *parser, rbs_token_t tok, bool syntax_error, const char *fmt, ...) RBS_ATTRIBUTE_FORMAT(4, 5);
128128

129-
bool parse_type(rbs_parser_t *parser, rbs_node_t **type);
130-
bool parse_method_type(rbs_parser_t *parser, rbs_methodtype_t **method_type);
131-
bool parse_signature(rbs_parser_t *parser, rbs_signature_t **signature);
129+
bool rbs_parse_type(rbs_parser_t *parser, rbs_node_t **type);
130+
bool rbs_parse_method_type(rbs_parser_t *parser, rbs_methodtype_t **method_type);
131+
bool rbs_parse_signature(rbs_parser_t *parser, rbs_signature_t **signature);
132132

133133
#endif

0 commit comments

Comments
 (0)