2020 strlen(str) \
2121 )
2222
23- #define INTERN_TOKEN (parser , tok ) \
24- rbs_constant_pool_insert_shared_with_encoding( \
25- &parser->constant_pool, \
26- (const uint8_t *) rbs_peek_token(parser->rbs_lexer_t , tok), \
27- rbs_token_bytes(tok), \
28- (void *) parser->rbs_lexer_t ->encoding \
23+ #define INTERN_TOKEN (parser , tok ) \
24+ rbs_constant_pool_insert_shared_with_encoding( \
25+ &parser->constant_pool, \
26+ (const uint8_t *) rbs_peek_token(parser->lexer , tok), \
27+ rbs_token_bytes(tok), \
28+ parser->lexer ->encoding \
2929 )
3030
3131#define KEYWORD_CASES \
@@ -128,7 +128,7 @@ static bool parse_simple(rbs_parser_t *parser, rbs_node_t **type);
128128static rbs_string_t rbs_parser_peek_current_token (rbs_parser_t * parser ) {
129129 rbs_range_t rg = parser -> current_token .range ;
130130
131- const char * start = parser -> rbs_lexer_t -> string .start + rg .start .byte_pos ;
131+ const char * start = parser -> lexer -> string .start + rg .start .byte_pos ;
132132 size_t length = rg .end .byte_pos - rg .start .byte_pos ;
133133
134134 return rbs_string_new (start , start + length );
@@ -189,7 +189,7 @@ static bool parse_type_name(rbs_parser_t *parser, TypeNameKind kind, rbs_range_t
189189 .end = parser -> current_token .range .end
190190 };
191191 rbs_location_t * loc = rbs_location_new (ALLOCATOR (), namespace_range );
192- rbs_namespace_t * namespace = rbs_namespace_new (ALLOCATOR (), loc , path , absolute );
192+ rbs_namespace_t * ns = rbs_namespace_new (ALLOCATOR (), loc , path , absolute );
193193
194194 switch (parser -> current_token .type ) {
195195 case tLIDENT :
@@ -213,7 +213,7 @@ success: {
213213 rbs_location_t * symbolLoc = rbs_location_current_token (parser );
214214 rbs_constant_id_t name = INTERN_TOKEN (parser , parser -> current_token );
215215 rbs_ast_symbol_t * symbol = rbs_ast_symbol_new (ALLOCATOR (), symbolLoc , & parser -> constant_pool , name );
216- * type_name = rbs_type_name_new (ALLOCATOR (), rbs_location_new (ALLOCATOR (), * rg ), namespace , symbol );
216+ * type_name = rbs_type_name_new (ALLOCATOR (), rbs_location_new (ALLOCATOR (), * rg ), ns , symbol );
217217 return true;
218218}
219219
@@ -317,7 +317,7 @@ static bool parse_function_param(rbs_parser_t *parser, rbs_types_function_param_
317317 return false;
318318 }
319319
320- rbs_string_t unquoted_str = rbs_unquote_string (ALLOCATOR (), rbs_parser_peek_current_token (parser ), parser -> rbs_lexer_t -> encoding );
320+ rbs_string_t unquoted_str = rbs_unquote_string (ALLOCATOR (), rbs_parser_peek_current_token (parser ), parser -> lexer -> encoding );
321321 rbs_location_t * symbolLoc = rbs_location_current_token (parser );
322322 rbs_constant_id_t constant_id = rbs_constant_pool_insert_string (& parser -> constant_pool , unquoted_str );
323323 rbs_ast_symbol_t * name = rbs_ast_symbol_new (ALLOCATOR (), symbolLoc , & parser -> constant_pool , constant_id );
@@ -334,9 +334,9 @@ static bool parse_function_param(rbs_parser_t *parser, rbs_types_function_param_
334334static rbs_constant_id_t intern_token_start_end (rbs_parser_t * parser , rbs_token_t start_token , rbs_token_t end_token ) {
335335 return rbs_constant_pool_insert_shared_with_encoding (
336336 & parser -> constant_pool ,
337- (const uint8_t * ) rbs_peek_token (parser -> rbs_lexer_t , start_token ),
337+ (const uint8_t * ) rbs_peek_token (parser -> lexer , start_token ),
338338 end_token .range .end .byte_pos - start_token .range .start .byte_pos ,
339- parser -> rbs_lexer_t -> encoding
339+ parser -> lexer -> encoding
340340 );
341341}
342342
@@ -902,7 +902,7 @@ static bool parse_record_attributes(rbs_parser_t *parser, rbs_hash_t **fields) {
902902*/
903903NODISCARD
904904static bool parse_symbol (rbs_parser_t * parser , rbs_location_t * location , rbs_types_literal_t * * symbol ) {
905- size_t offset_bytes = parser -> rbs_lexer_t -> encoding -> char_width ((const uint8_t * ) ":" , (size_t ) 1 );
905+ size_t offset_bytes = parser -> lexer -> encoding -> char_width ((const uint8_t * ) ":" , (size_t ) 1 );
906906 size_t bytes = rbs_token_bytes (parser -> current_token ) - offset_bytes ;
907907
908908 rbs_ast_symbol_t * literal ;
@@ -911,7 +911,7 @@ static bool parse_symbol(rbs_parser_t *parser, rbs_location_t *location, rbs_typ
911911 case tSYMBOL : {
912912 rbs_location_t * symbolLoc = rbs_location_current_token (parser );
913913
914- char * buffer = rbs_peek_token (parser -> rbs_lexer_t , parser -> current_token );
914+ char * buffer = rbs_peek_token (parser -> lexer , parser -> current_token );
915915 rbs_constant_id_t constant_id = rbs_constant_pool_insert_shared (
916916 & parser -> constant_pool ,
917917 (const uint8_t * ) buffer + offset_bytes ,
@@ -927,7 +927,7 @@ static bool parse_symbol(rbs_parser_t *parser, rbs_location_t *location, rbs_typ
927927
928928 rbs_string_t symbol = rbs_string_new (current_token .start + offset_bytes , current_token .end );
929929
930- rbs_string_t unquoted_symbol = rbs_unquote_string (ALLOCATOR (), symbol , parser -> rbs_lexer_t -> encoding );
930+ rbs_string_t unquoted_symbol = rbs_unquote_string (ALLOCATOR (), symbol , parser -> lexer -> encoding );
931931
932932 rbs_constant_id_t constant_id = rbs_constant_pool_insert_string (& parser -> constant_pool , unquoted_symbol );
933933
@@ -951,9 +951,9 @@ static bool parse_symbol(rbs_parser_t *parser, rbs_location_t *location, rbs_typ
951951 */
952952NODISCARD
953953static bool parse_instance_type (rbs_parser_t * parser , bool parse_alias , rbs_node_t * * type ) {
954- TypeNameKind expected_kind = INTERFACE_NAME | CLASS_NAME ;
954+ TypeNameKind expected_kind = ( TypeNameKind ) ( INTERFACE_NAME | CLASS_NAME ) ;
955955 if (parse_alias ) {
956- expected_kind |= ALIAS_NAME ;
956+ expected_kind = ( TypeNameKind ) ( expected_kind | ALIAS_NAME ) ;
957957 }
958958
959959 rbs_range_t name_range ;
@@ -1157,7 +1157,7 @@ static bool parse_simple(rbs_parser_t *parser, rbs_node_t **type) {
11571157 case tDQSTRING : {
11581158 rbs_location_t * loc = rbs_location_current_token (parser );
11591159
1160- rbs_string_t unquoted_str = rbs_unquote_string (ALLOCATOR (), rbs_parser_peek_current_token (parser ), parser -> rbs_lexer_t -> encoding );
1160+ rbs_string_t unquoted_str = rbs_unquote_string (ALLOCATOR (), rbs_parser_peek_current_token (parser ), parser -> lexer -> encoding );
11611161 rbs_node_t * literal = (rbs_node_t * ) rbs_ast_string_new (ALLOCATOR (), loc , unquoted_str );
11621162 * type = (rbs_node_t * ) rbs_types_literal_new (ALLOCATOR (), loc , literal );
11631163 return true;
@@ -1172,7 +1172,7 @@ static bool parse_simple(rbs_parser_t *parser, rbs_node_t **type) {
11721172 return true;
11731173 }
11741174 case tUIDENT : {
1175- const char * name_str = rbs_peek_token (parser -> rbs_lexer_t , parser -> current_token );
1175+ const char * name_str = rbs_peek_token (parser -> lexer , parser -> current_token );
11761176 size_t name_len = rbs_token_bytes (parser -> current_token );
11771177
11781178 rbs_constant_id_t name = rbs_constant_pool_find (& parser -> constant_pool , (const uint8_t * ) name_str , name_len );
@@ -1606,12 +1606,12 @@ static bool parse_annotation(rbs_parser_t *parser, rbs_ast_annotation_t **annota
16061606 rbs_range_t rg = parser -> current_token .range ;
16071607
16081608 size_t offset_bytes =
1609- parser -> rbs_lexer_t -> encoding -> char_width ((const uint8_t * ) "%" , (size_t ) 1 ) +
1610- parser -> rbs_lexer_t -> encoding -> char_width ((const uint8_t * ) "a" , (size_t ) 1 );
1609+ parser -> lexer -> encoding -> char_width ((const uint8_t * ) "%" , (size_t ) 1 ) +
1610+ parser -> lexer -> encoding -> char_width ((const uint8_t * ) "a" , (size_t ) 1 );
16111611
16121612 rbs_string_t str = rbs_string_new (
1613- parser -> rbs_lexer_t -> string .start + rg .start .byte_pos + offset_bytes ,
1614- parser -> rbs_lexer_t -> string .end
1613+ parser -> lexer -> string .start + rg .start .byte_pos + offset_bytes ,
1614+ parser -> lexer -> string .end
16151615 );
16161616
16171617 // Assumes the input is ASCII compatible
@@ -1640,8 +1640,8 @@ static bool parse_annotation(rbs_parser_t *parser, rbs_ast_annotation_t **annota
16401640 return false;
16411641 }
16421642
1643- size_t open_bytes = parser -> rbs_lexer_t -> encoding -> char_width ((const uint8_t * ) & open_char , (size_t ) 1 );
1644- size_t close_bytes = parser -> rbs_lexer_t -> encoding -> char_width ((const uint8_t * ) & close_char , (size_t ) 1 );
1643+ size_t open_bytes = parser -> lexer -> encoding -> char_width ((const uint8_t * ) & open_char , (size_t ) 1 );
1644+ size_t close_bytes = parser -> lexer -> encoding -> char_width ((const uint8_t * ) & close_char , (size_t ) 1 );
16451645
16461646 rbs_string_t current_token = rbs_parser_peek_current_token (parser );
16471647 size_t total_offset = offset_bytes + open_bytes ;
@@ -1705,9 +1705,9 @@ static bool parse_method_name(rbs_parser_t *parser, rbs_range_t *range, rbs_ast_
17051705
17061706 rbs_constant_id_t constant_id = rbs_constant_pool_insert_shared_with_encoding (
17071707 & parser -> constant_pool ,
1708- (const uint8_t * ) parser -> rbs_lexer_t -> string .start + range -> start .byte_pos ,
1708+ (const uint8_t * ) parser -> lexer -> string .start + range -> start .byte_pos ,
17091709 range -> end .byte_pos - range -> start .byte_pos ,
1710- parser -> rbs_lexer_t -> encoding
1710+ parser -> lexer -> encoding
17111711 );
17121712
17131713 rbs_location_t * symbolLoc = rbs_location_new (ALLOCATOR (), * range );
@@ -1728,7 +1728,7 @@ static bool parse_method_name(rbs_parser_t *parser, rbs_range_t *range, rbs_ast_
17281728 }
17291729 case tQIDENT : {
17301730 rbs_string_t string = rbs_parser_peek_current_token (parser );
1731- rbs_string_t unquoted_str = rbs_unquote_string (ALLOCATOR (), string , parser -> rbs_lexer_t -> encoding );
1731+ rbs_string_t unquoted_str = rbs_unquote_string (ALLOCATOR (), string , parser -> lexer -> encoding );
17321732 rbs_constant_id_t constant_id = rbs_constant_pool_insert_string (& parser -> constant_pool , unquoted_str );
17331733 rbs_location_t * symbolLoc = rbs_location_current_token (parser );
17341734 * symbol = rbs_ast_symbol_new (ALLOCATOR (), symbolLoc , & parser -> constant_pool , constant_id );
@@ -2031,7 +2031,7 @@ static bool parse_mixin_member(rbs_parser_t *parser, bool from_interface, rbs_po
20312031 rbs_type_name_t * name = NULL ;
20322032 CHECK_PARSE (class_instance_name (
20332033 parser ,
2034- from_interface ? INTERFACE_NAME : (INTERFACE_NAME | CLASS_NAME ),
2034+ from_interface ? INTERFACE_NAME : (TypeNameKind ) ( INTERFACE_NAME | CLASS_NAME ),
20352035 args ,
20362036 & name_range ,
20372037 & args_range ,
@@ -2496,7 +2496,7 @@ static bool parse_module_self_types(rbs_parser_t *parser, rbs_node_list_t *array
24962496
24972497 rbs_range_t name_range ;
24982498 rbs_type_name_t * module_name = NULL ;
2499- CHECK_PARSE (parse_type_name (parser , CLASS_NAME | INTERFACE_NAME , & name_range , & module_name ));
2499+ CHECK_PARSE (parse_type_name (parser , ( TypeNameKind ) ( CLASS_NAME | INTERFACE_NAME ) , & name_range , & module_name ));
25002500 self_range .end = name_range .end ;
25012501
25022502 rbs_node_list_t * args = rbs_node_list_new (ALLOCATOR ());
@@ -2959,7 +2959,7 @@ static bool parse_decl(rbs_parser_t *parser, rbs_node_t **decl) {
29592959 | {} <> (empty -- returns empty namespace)
29602960*/
29612961NODISCARD
2962- static bool parse_namespace (rbs_parser_t * parser , rbs_range_t * rg , rbs_namespace_t * * namespace ) {
2962+ static bool parse_namespace (rbs_parser_t * parser , rbs_range_t * rg , rbs_namespace_t * * out_ns ) {
29632963 bool is_absolute = false;
29642964
29652965 if (parser -> next_token .type == pCOLON2 ) {
@@ -2990,7 +2990,7 @@ static bool parse_namespace(rbs_parser_t *parser, rbs_range_t *rg, rbs_namespace
29902990 }
29912991 }
29922992
2993- * namespace = rbs_namespace_new (ALLOCATOR (), rbs_location_new (ALLOCATOR (), * rg ), path , is_absolute );
2993+ * out_ns = rbs_namespace_new (ALLOCATOR (), rbs_location_new (ALLOCATOR (), * rg ), path , is_absolute );
29942994 return true;
29952995}
29962996
@@ -3005,8 +3005,8 @@ NODISCARD
30053005static bool parse_use_clauses (rbs_parser_t * parser , rbs_node_list_t * clauses ) {
30063006 while (true) {
30073007 rbs_range_t namespace_range = NULL_RANGE ;
3008- rbs_namespace_t * namespace = NULL ;
3009- CHECK_PARSE (parse_namespace (parser , & namespace_range , & namespace ));
3008+ rbs_namespace_t * ns = NULL ;
3009+ CHECK_PARSE (parse_namespace (parser , & namespace_range , & ns ));
30103010
30113011 switch (parser -> next_token .type ) {
30123012 case tLIDENT :
@@ -3020,7 +3020,7 @@ static bool parse_use_clauses(rbs_parser_t *parser, rbs_node_list_t *clauses) {
30203020
30213021 rbs_location_t * symbolLoc = rbs_location_current_token (parser );
30223022 rbs_ast_symbol_t * symbol = rbs_ast_symbol_new (ALLOCATOR (), symbolLoc , & parser -> constant_pool , INTERN_TOKEN (parser , parser -> current_token ));
3023- rbs_type_name_t * type_name = rbs_type_name_new (ALLOCATOR (), rbs_location_new (ALLOCATOR (), type_name_range ), namespace , symbol );
3023+ rbs_type_name_t * type_name = rbs_type_name_new (ALLOCATOR (), rbs_location_new (ALLOCATOR (), type_name_range ), ns , symbol );
30243024
30253025 rbs_range_t keyword_range = NULL_RANGE ;
30263026 rbs_range_t new_name_range = NULL_RANGE ;
@@ -3063,7 +3063,7 @@ static bool parse_use_clauses(rbs_parser_t *parser, rbs_node_list_t *clauses) {
30633063 rbs_loc_add_required_child (loc , INTERN ("namespace" ), namespace_range );
30643064 rbs_loc_add_required_child (loc , INTERN ("star" ), star_range );
30653065
3066- rbs_ast_directives_use_wildcard_clause_t * clause = rbs_ast_directives_use_wildcard_clause_new (ALLOCATOR (), loc , namespace );
3066+ rbs_ast_directives_use_wildcard_clause_t * clause = rbs_ast_directives_use_wildcard_clause_new (ALLOCATOR (), loc , ns );
30673067 rbs_node_list_append (clauses , (rbs_node_t * ) clause );
30683068
30693069 break ;
@@ -3110,21 +3110,21 @@ static bool parse_use_directive(rbs_parser_t *parser, rbs_ast_directives_use_t *
31103110}
31113111
31123112static rbs_ast_comment_t * parse_comment_lines (rbs_parser_t * parser , rbs_comment_t * com ) {
3113- size_t hash_bytes = parser -> rbs_lexer_t -> encoding -> char_width ((const uint8_t * ) "#" , (size_t ) 1 );
3114- size_t space_bytes = parser -> rbs_lexer_t -> encoding -> char_width ((const uint8_t * ) " " , (size_t ) 1 );
3113+ size_t hash_bytes = parser -> lexer -> encoding -> char_width ((const uint8_t * ) "#" , (size_t ) 1 );
3114+ size_t space_bytes = parser -> lexer -> encoding -> char_width ((const uint8_t * ) " " , (size_t ) 1 );
31153115
31163116 rbs_buffer_t rbs_buffer ;
31173117 rbs_buffer_init (ALLOCATOR (), & rbs_buffer );
31183118
31193119 for (size_t i = 0 ; i < com -> line_tokens_count ; i ++ ) {
31203120 rbs_token_t tok = com -> line_tokens [i ];
31213121
3122- const char * comment_start = parser -> rbs_lexer_t -> string .start + tok .range .start .byte_pos + hash_bytes ;
3122+ const char * comment_start = parser -> lexer -> string .start + tok .range .start .byte_pos + hash_bytes ;
31233123 size_t comment_bytes = RBS_RANGE_BYTES (tok .range ) - hash_bytes ;
31243124
31253125 rbs_string_t str = rbs_string_new (
31263126 comment_start ,
3127- parser -> rbs_lexer_t -> string .end
3127+ parser -> lexer -> string .end
31283128 );
31293129
31303130 // Assumes the input is ASCII compatible
@@ -3344,7 +3344,7 @@ void rbs_parser_advance(rbs_parser_t *parser) {
33443344 break ;
33453345 }
33463346
3347- parser -> next_token3 = rbs_lexer_next_token (parser -> rbs_lexer_t );
3347+ parser -> next_token3 = rbs_lexer_next_token (parser -> lexer );
33483348
33493349 if (parser -> next_token3 .type == tCOMMENT ) {
33503350 // skip
@@ -3436,7 +3436,7 @@ rbs_parser_t *rbs_parser_new(rbs_string_t string, const rbs_encoding_t *encoding
34363436 rbs_parser_t * parser = rbs_allocator_alloc (allocator , rbs_parser_t );
34373437
34383438 * parser = (rbs_parser_t ) {
3439- .rbs_lexer_t = lexer ,
3439+ .lexer = lexer ,
34403440
34413441 .current_token = NullToken ,
34423442 .next_token = NullToken ,
0 commit comments