Skip to content

Commit 7be7ddc

Browse files
committed
Prefix token_type_str function
1 parent 1c987b3 commit 7be7ddc

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

ext/rbs_extension/main.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ static NORETURN(void) raise_error(rbs_error_t *error, VALUE buffer) {
2323
}
2424

2525
VALUE location = rbs_new_location(buffer, error->token.range);
26-
VALUE type = rb_str_new_cstr(token_type_str(error->token.type));
26+
VALUE type = rb_str_new_cstr(rbs_token_type_str(error->token.type));
2727

2828
VALUE rb_error = rb_funcall(
2929
RBS_ParsingError,
@@ -112,7 +112,7 @@ static VALUE parse_type_try(VALUE a) {
112112
if (RB_TEST(arg->require_eof)) {
113113
parser_advance(parser);
114114
if (parser->current_token.type != pEOF) {
115-
set_error(parser, parser->current_token, true, "expected a token `%s`", token_type_str(pEOF));
115+
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
}
@@ -202,7 +202,7 @@ static VALUE parse_method_type_try(VALUE a) {
202202
if (RB_TEST(arg->require_eof)) {
203203
parser_advance(parser);
204204
if (parser->current_token.type != pEOF) {
205-
set_error(parser, parser->current_token, true, "expected a token `%s`", token_type_str(pEOF));
205+
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
}
@@ -292,7 +292,7 @@ static VALUE rbsparser_lex(VALUE self, VALUE buffer, VALUE end_pos) {
292292
rbs_token_t token = NullToken;
293293
while (token.type != pEOF) {
294294
token = rbsparser_next_token(lexer);
295-
VALUE type = ID2SYM(rb_intern(token_type_str(token.type)));
295+
VALUE type = ID2SYM(rb_intern(rbs_token_type_str(token.type)));
296296
VALUE location = rbs_new_location(buffer, token.range);
297297
VALUE pair = rb_ary_new3(2, type, location);
298298
rb_ary_push(results, pair);

include/rbs/lexer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ int rbs_token_bytes(rbs_token_t tok);
149149
#define rbs_nonnull_pos_or(pos1, pos2) (rbs_null_position_p(pos1) ? pos2 : pos1)
150150
#define RBS_RANGE_BYTES(range) (range.end.byte_pos - range.start.byte_pos)
151151

152-
const char *token_type_str(enum RBSTokenType type);
152+
const char *rbs_token_type_str(enum RBSTokenType type);
153153

154154
/**
155155
* Read next character.

src/lexstate.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ rbs_token_t NullToken = { .type = NullType, .range = {} };
9393
rbs_position_t NullPosition = { -1, -1, -1, -1 };
9494
rbs_range_t NULL_RANGE = { { -1, -1, -1, -1 }, { -1, -1, -1, -1 } };
9595

96-
const char *token_type_str(enum RBSTokenType type) {
96+
const char *rbs_token_type_str(enum RBSTokenType type) {
9797
return RBS_TOKENTYPE_NAMES[type];
9898
}
9999

src/parser.c

+6-6
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ void rbs_parser_private_thing(rbs_parser_t *parser) {
7373

7474
#define ASSERT_TOKEN(parser, expected_type) \
7575
if (parser->current_token.type != expected_type) { \
76-
set_error(parser, parser->current_token, true, "expected a token `%s`", token_type_str(expected_type)); \
76+
set_error(parser, parser->current_token, true, "expected a token `%s`", rbs_token_type_str(expected_type)); \
7777
return false; \
7878
}
7979

@@ -3299,10 +3299,10 @@ bool parser_insert_typevar(rbs_parser_t *parser, rbs_constant_id_t id) {
32993299
}
33003300

33013301
void print_parser(rbs_parser_t *parser) {
3302-
printf(" current_token = %s (%d...%d)\n", token_type_str(parser->current_token.type), parser->current_token.range.start.char_pos, parser->current_token.range.end.char_pos);
3303-
printf(" next_token = %s (%d...%d)\n", token_type_str(parser->next_token.type), parser->next_token.range.start.char_pos, parser->next_token.range.end.char_pos);
3304-
printf(" next_token2 = %s (%d...%d)\n", token_type_str(parser->next_token2.type), parser->next_token2.range.start.char_pos, parser->next_token2.range.end.char_pos);
3305-
printf(" next_token3 = %s (%d...%d)\n", token_type_str(parser->next_token3.type), parser->next_token3.range.start.char_pos, parser->next_token3.range.end.char_pos);
3302+
printf(" current_token = %s (%d...%d)\n", rbs_token_type_str(parser->current_token.type), parser->current_token.range.start.char_pos, parser->current_token.range.end.char_pos);
3303+
printf(" next_token = %s (%d...%d)\n", rbs_token_type_str(parser->next_token.type), parser->next_token.range.start.char_pos, parser->next_token.range.end.char_pos);
3304+
printf(" next_token2 = %s (%d...%d)\n", rbs_token_type_str(parser->next_token2.type), parser->next_token2.range.start.char_pos, parser->next_token2.range.end.char_pos);
3305+
printf(" next_token3 = %s (%d...%d)\n", rbs_token_type_str(parser->next_token3.type), parser->next_token3.range.start.char_pos, parser->next_token3.range.end.char_pos);
33063306
}
33073307

33083308
void parser_advance(rbs_parser_t *parser) {
@@ -3332,7 +3332,7 @@ void parser_advance(rbs_parser_t *parser) {
33323332
void rbs_print_token(rbs_token_t tok) {
33333333
printf(
33343334
"%s char=%d...%d\n",
3335-
token_type_str(tok.type),
3335+
rbs_token_type_str(tok.type),
33363336
tok.range.start.char_pos,
33373337
tok.range.end.char_pos
33383338
);

0 commit comments

Comments
 (0)