@@ -106,7 +106,7 @@ typedef struct id_table {
106
106
struct id_table * next ;
107
107
} id_table ;
108
108
109
- const TypeValidation SkipValidation = {
109
+ const rbs_type_validation_t SkipValidation = {
110
110
.no_void = false,
111
111
.no_void_allowed_here = false,
112
112
.no_self = false,
@@ -127,8 +127,8 @@ static rbs_location_t *rbs_location_current_token(rbs_parser_t *parser) {
127
127
return rbs_location_new (ALLOCATOR (), parser -> current_token .range );
128
128
}
129
129
130
- static bool parse_optional (rbs_parser_t * parser , rbs_node_t * * optional , TypeValidation validation );
131
- static bool parse_simple (rbs_parser_t * parser , rbs_node_t * * type , TypeValidation validation );
130
+ static bool parse_optional (rbs_parser_t * parser , rbs_node_t * * optional , rbs_type_validation_t validation );
131
+ static bool parse_simple (rbs_parser_t * parser , rbs_node_t * * type , rbs_type_validation_t validation );
132
132
133
133
/**
134
134
* @returns A borrowed copy of the current token, which does *not* need to be freed.
@@ -251,7 +251,7 @@ error_handling: {
251
251
| {} type `,` ... `,` <type> eol
252
252
*/
253
253
NODISCARD
254
- static bool parse_type_list (rbs_parser_t * parser , enum RBSTokenType eol , rbs_node_list_t * types , TypeValidation validation ) {
254
+ static bool parse_type_list (rbs_parser_t * parser , enum RBSTokenType eol , rbs_node_list_t * types , rbs_type_validation_t validation ) {
255
255
while (true) {
256
256
rbs_node_t * type ;
257
257
CHECK_PARSE (rbs_parse_type (parser , & type , validation ));
@@ -296,7 +296,7 @@ static bool is_keyword_token(enum RBSTokenType type) {
296
296
| {} type <param>
297
297
*/
298
298
NODISCARD
299
- static bool parse_function_param (rbs_parser_t * parser , rbs_types_function_param_t * * function_param , TypeValidation validation ) {
299
+ static bool parse_function_param (rbs_parser_t * parser , rbs_types_function_param_t * * function_param , rbs_type_validation_t validation ) {
300
300
rbs_range_t type_range ;
301
301
type_range .start = parser -> next_token .range .start ;
302
302
rbs_node_t * type ;
@@ -464,7 +464,7 @@ static bool parser_advance_if(rbs_parser_t *parser, enum RBSTokenType type) {
464
464
| {} `**` <function_param>
465
465
*/
466
466
NODISCARD
467
- static bool parse_params (rbs_parser_t * parser , method_params * params , TypeValidation validation ) {
467
+ static bool parse_params (rbs_parser_t * parser , method_params * params , rbs_type_validation_t validation ) {
468
468
if (parser -> next_token .type == pQUESTION && parser -> next_token2 .type == pRPAREN ) {
469
469
params -> required_positionals = NULL ;
470
470
rbs_parser_advance (parser );
@@ -630,7 +630,7 @@ static bool parse_params(rbs_parser_t *parser, method_params *params, TypeValida
630
630
| {} simple_type <`?`>
631
631
*/
632
632
NODISCARD
633
- static bool parse_optional (rbs_parser_t * parser , rbs_node_t * * optional , TypeValidation validation ) {
633
+ static bool parse_optional (rbs_parser_t * parser , rbs_node_t * * optional , rbs_type_validation_t validation ) {
634
634
rbs_range_t rg ;
635
635
rg .start = parser -> next_token .range .start ;
636
636
@@ -666,7 +666,7 @@ static void initialize_method_params(method_params *params, rbs_allocator_t *all
666
666
| {} `[` `self` `:` type <`]`>
667
667
*/
668
668
NODISCARD
669
- static bool parse_self_type_binding (rbs_parser_t * parser , rbs_node_t * * self_type , TypeValidation validation ) {
669
+ static bool parse_self_type_binding (rbs_parser_t * parser , rbs_node_t * * self_type , rbs_type_validation_t validation ) {
670
670
if (parser -> next_token .type == pLBRACKET ) {
671
671
rbs_parser_advance (parser );
672
672
ADVANCE_ASSERT (parser , kSELF );
@@ -694,13 +694,13 @@ typedef struct {
694
694
| {} self_type_binding? `->` <optional>
695
695
*/
696
696
NODISCARD
697
- static bool parse_function (rbs_parser_t * parser , bool accept_type_binding , parse_function_result * * result , TypeValidation validation ) {
697
+ static bool parse_function (rbs_parser_t * parser , bool accept_type_binding , parse_function_result * * result , rbs_type_validation_t validation ) {
698
698
rbs_node_t * function = NULL ;
699
699
rbs_types_block_t * block = NULL ;
700
700
rbs_node_t * function_self_type = NULL ;
701
701
rbs_range_t function_range ;
702
702
function_range .start = parser -> current_token .range .start ;
703
- TypeValidation no_void_allowed_here = validation ;
703
+ rbs_type_validation_t no_void_allowed_here = validation ;
704
704
no_void_allowed_here .no_void_allowed_here = true;
705
705
706
706
method_params params ;
@@ -814,7 +814,7 @@ static bool parse_function(rbs_parser_t *parser, bool accept_type_binding, parse
814
814
proc_type ::= {`^`} <function>
815
815
*/
816
816
NODISCARD
817
- static bool parse_proc_type (rbs_parser_t * parser , rbs_types_proc_t * * proc , TypeValidation validation ) {
817
+ static bool parse_proc_type (rbs_parser_t * parser , rbs_types_proc_t * * proc , rbs_type_validation_t validation ) {
818
818
rbs_position_t start = parser -> current_token .range .start ;
819
819
parse_function_result * result = rbs_allocator_alloc (ALLOCATOR (), parse_function_result );
820
820
CHECK_PARSE (parse_function (parser , true, & result , validation ));
@@ -842,7 +842,7 @@ static void check_key_duplication(rbs_parser_t *parser, rbs_hash_t *fields, rbs_
842
842
| {} literal_type `=>` <type>
843
843
*/
844
844
NODISCARD
845
- static bool parse_record_attributes (rbs_parser_t * parser , rbs_hash_t * * fields , TypeValidation validation ) {
845
+ static bool parse_record_attributes (rbs_parser_t * parser , rbs_hash_t * * fields , rbs_type_validation_t validation ) {
846
846
* fields = rbs_hash_new (ALLOCATOR ());
847
847
848
848
if (parser -> next_token .type == pRBRACE ) return true;
@@ -999,7 +999,7 @@ static bool parse_instance_type(rbs_parser_t *parser, bool parse_alias, rbs_node
999
999
if (parser -> next_token .type == pLBRACKET ) {
1000
1000
rbs_parser_advance (parser );
1001
1001
args_range .start = parser -> current_token .range .start ;
1002
- TypeValidation no_void_allowed_here = {
1002
+ rbs_type_validation_t no_void_allowed_here = {
1003
1003
.no_void = false,
1004
1004
.no_void_allowed_here = true,
1005
1005
.no_self = false,
@@ -1092,7 +1092,7 @@ static bool parser_typevar_member(rbs_parser_t *parser, rbs_constant_id_t id) {
1092
1092
| {} `^` <function>
1093
1093
*/
1094
1094
NODISCARD
1095
- static bool parse_simple (rbs_parser_t * parser , rbs_node_t * * type , TypeValidation validation ) {
1095
+ static bool parse_simple (rbs_parser_t * parser , rbs_node_t * * type , rbs_type_validation_t validation ) {
1096
1096
rbs_parser_advance (parser );
1097
1097
1098
1098
if (parser -> current_token .type != kVOID ) {
@@ -1289,7 +1289,7 @@ static bool parse_simple(rbs_parser_t *parser, rbs_node_t **type, TypeValidation
1289
1289
| {} <optional>
1290
1290
*/
1291
1291
NODISCARD
1292
- static bool parse_intersection (rbs_parser_t * parser , rbs_node_t * * type , TypeValidation validation ) {
1292
+ static bool parse_intersection (rbs_parser_t * parser , rbs_node_t * * type , rbs_type_validation_t validation ) {
1293
1293
rbs_range_t rg ;
1294
1294
rg .start = parser -> next_token .range .start ;
1295
1295
@@ -1321,7 +1321,7 @@ static bool parse_intersection(rbs_parser_t *parser, rbs_node_t **type, TypeVali
1321
1321
union ::= {} intersection '|' ... '|' <intersection>
1322
1322
| {} <intersection>
1323
1323
*/
1324
- bool rbs_parse_type (rbs_parser_t * parser , rbs_node_t * * type , TypeValidation validation ) {
1324
+ bool rbs_parse_type (rbs
10670
_parser_t * parser , rbs_node_t * * type , rbs_type_validation_t validation ) {
1325
1325
rbs_range_t rg ;
1326
1326
rg .start = parser -> next_token .range .start ;
1327
1327
rbs_node_list_t * union_types = rbs_node_list_new (ALLOCATOR ());
@@ -1416,7 +1416,7 @@ static bool parse_type_params(rbs_parser_t *parser, rbs_range_t *rg, bool module
1416
1416
if (parser -> next_token .type == pLT ) {
1417
1417
rbs_parser_advance (parser );
1418
1418
upper_bound_range .start = parser -> current_token .range .start ;
1419
- CHECK_PARSE (rbs_parse_type (parser , & upper_bound , (TypeValidation ) { .no_void = true, .no_self = true, .no_classish = true }));
1419
+ CHECK_PARSE (rbs_parse_type (parser , & upper_bound , (rbs_type_validation_t ) { .no_void = true, .no_self = true, .no_classish = true }));
1420
1420
upper_bound_range .end = parser -> current_token .range .end ;
1421
1421
}
1422
1422
@@ -1426,7 +1426,7 @@ static bool parse_type_params(rbs_parser_t *parser, rbs_range_t *rg, bool module
1426
1426
rbs_parser_advance (parser );
1427
1427
1428
1428
default_type_range .start = parser -> current_token .range .start ;
1429
- CHECK_PARSE (rbs_parse_type (parser , & default_type , (TypeValidation ) { .no_void = true, .no_void_allowed_here = true, .no_self = true, .no_classish = true }));
1429
+ CHECK_PARSE (rbs_parse_type (parser , & default_type , (rbs_type_validation_t ) { .no_void = true, .no_void_allowed_here = true, .no_self = true, .no_classish = true }));
1430
1430
default_type_range .end = parser -> current_token .range .end ;
1431
1431
1432
1432
required_param_allowed = false;
@@ -1494,7 +1494,7 @@ static bool parser_pop_typevar_table(rbs_parser_t *parser) {
1494
1494
method_type ::= {} type_params <function>
1495
1495
*/
1496
1496
// TODO: Should this be NODISCARD?
1497
- bool rbs_parse_method_type (rbs_parser_t * parser , rbs_method_type_t * * method_type , TypeValidation validation ) {
1497
+ bool rbs_parse_method_type (rbs_parser_t * parser , rbs_method_type_t * * method_type , rbs_type_validation_t validation ) {
1498
1498
rbs_parser_push_typevar_table (parser , false);
1499
1499
1500
1500
rbs_range_t rg ;
@@ -1543,7 +1543,7 @@ static bool parse_global_decl(rbs_parser_t *parser, rbs_node_list_t *annotations
1543
1543
rbs_range_t colon_range = parser -> current_token .range ;
1544
1544
1545
1545
rbs_node_t * type ;
1546
- CHECK_PARSE (rbs_parse_type (parser , & type , (TypeValidation ) { .no_void = true, .no_self = true, .no_classish = true }));
1546
+ CHECK_PARSE (rbs_parse_type (parser , & type , (rbs_type_validation_t ) { .no_void = true, .no_self = true, .no_classish = true }));
1547
1547
decl_range .end = parser -> current_token .range .end ;
1548
1548
1549
1549
rbs_location_t * loc = rbs_location_new (ALLOCATOR (), decl_range );
@@ -1573,7 +1573,7 @@ static bool parse_const_decl(rbs_parser_t *parser, rbs_node_list_t *annotations,
1573
1573
rbs_range_t colon_range = parser -> current_token .range ;
1574
1574
1575
1575
rbs_node_t * type ;
1576
- CHECK_PARSE (rbs_parse_type (parser , & type , (TypeValidation ) { .no_void = true, .no_self = true, .no_classish = true }));
1576
+ CHECK_PARSE (rbs_parse_type (parser , & type , (rbs_type_validation_t ) { .no_void = true, .no_self = true, .no_classish = true }));
1577
1577
1578
1578
decl_range .end = parser -> current_token .range .end ;
1579
1579
@@ -1613,7 +1613,7 @@ static bool parse_type_decl(rbs_parser_t *parser, rbs_position_t comment_pos, rb
1613
1613
rbs_range_t eq_range = parser -> current_token .range ;
1614
1614
1615
1615
rbs_node_t * type ;
1616
- CHECK_PARSE (rbs_parse_type (parser , & type , (TypeValidation ) { .no_void = true, .no_self = true, .no_classish = true }));
1616
+ CHECK_PARSE (rbs_parse_type (parser , & type , (rbs_type_validation_t ) { .no_void = true, .no_self = true, .no_classish = true }));
1617
1617
1618
1618
decl_range .end = parser -> current_token .range .end ;
1619
1619
@@ -1921,7 +1921,7 @@ static bool parse_member_def(rbs_parser_t *parser, bool instance_only, bool acce
1921
1921
case pLBRACKET :
1922
1922
case pQUESTION : {
1923
1923
rbs_method_type_t * method_type = NULL ;
1924
- CHECK_PARSE (rbs_parse_method_type (parser , & method_type , instance_only ? (TypeValidation ) { .no_void = true, .no_classish = true } : (TypeValidation ) { .no_void = true }));
1924
+ CHECK_PARSE (rbs_parse_method_type (parser , & method_type , instance_only ? (rbs_type_validation_t ) { .no_void = true, .no_classish = true } : (rbs_type_validation_t ) { .no_void = true }));
1925
1925
1926
1926
overload_range .end = parser -> current_token .range .end ;
1927
1927
rbs_location_t * loc = rbs_location_new (ALLOCATOR (), overload_range );
@@ -1996,7 +1996,7 @@ static bool parse_member_def(rbs_parser_t *parser, bool instance_only, bool acce
1996
1996
* @param kind
1997
1997
* */
1998
1998
NODISCARD
1999
- static bool class_instance_name (rbs_parser_t * parser , TypeNameKind kind , rbs_node_list_t * args , rbs_range_t * name_range , rbs_range_t * args_range , rbs_type_name_t * * name , TypeValidation validation ) {
1999
+ static bool class_instance_name (rbs_parser_t * parser , TypeNameKind kind , rbs_node_list_t * args , rbs_range_t * name_range , rbs_range_t * args_range , rbs_type_name_t * * name , rbs_type_validation_t validation ) {
2000
2000
rbs_parser_advance (parser );
2001
2001
2002
2002
rbs_type_name_t * type_name = NULL ;
@@ -2068,7 +2068,7 @@ static bool parse_mixin_member(rbs_parser_t *parser, bool from_interface, rbs_po
2068
2068
& name_range ,
2069
2069
& args_range ,
2070
2070
& name ,
2071
- (TypeValidation ) { .no_void = true, .no_void_allowed_here = true, .no_self = true }
2071
+ (rbs_type_validation_t ) { .no_void = true, .no_void_allowed_here = true, .no_self = true }
2072
2072
));
2073
2073
2074
2074
CHECK_PARSE (parser_pop_typevar_table (parser ));
@@ -2160,7 +2160,7 @@ static bool parse_alias_member(rbs_parser_t *parser, bool instance_only, rbs_pos
2160
2160
| {tA2IDENT} `:` <type>
2161
2161
*/
2162
2162
NODISCARD
2163
- static bool parse_variable_member (rbs_parser_t * parser , rbs_position_t comment_pos , rbs_node_list_t * annotations , rbs_node_t * * variable_member , TypeValidation validation ) {
2163
+ static bool parse_variable_member (rbs_parser_t * parser , rbs_position_t comment_pos , rbs_node_list_t * annotations , rbs_node_t * * variable_member , rbs_type_validation_t validation ) {
2164
2164
if (annotations -> length > 0 ) {
2165
2165
rbs_parser_set_error (parser , parser -> current_token , true, "annotation cannot be given to variable members" );
2166
2166
return false;
@@ -2385,7 +2385,7 @@ static bool parse_attribute_member(rbs_parser_t *parser, rbs_position_t comment_
2385
2385
rbs_parser_push_typevar_table (parser , is_kind == SINGLETON_KIND );
2386
2386
2387
2387
rbs_node_t * type ;
2388
- CHECK_PARSE (rbs_parse_type (parser , & type , (TypeValidation ) { .no_void = true }));
2388
+ CHECK_PARSE (rbs_parse_type (parser , & type , (rbs_type_validation_t ) { .no_void = true }));
2389
2389
2390
2390
CHECK_PARSE (parser_pop_typevar_table (parser ));
2391
2391
@@ -2538,7 +2538,7 @@ static bool parse_module_self_types(rbs_parser_t *parser, rbs_node_list_t *array
2538
2538
if (parser -> next_token .type == pLBRACKET ) {
2539
2539
rbs_parser_advance (parser );
2540
2540
args_range .start = parser -> current_token .range .start ;
2541
- CHECK_PARSE (parse_type_list (parser , pRBRACKET , args , (TypeValidation ) { .no_void = true, .no_void_allowed_here = true, .no_self = true, .no_classish = true }));
2541
+ CHECK_PARSE (parse_type_list (parser , pRBRACKET , args , (rbs_type_validation_t ) { .no_void = true, .no_void_allowed_here = true, .no_self = true, .no_classish = true }));
2542
2542
rbs_parser_advance (parser );
2543
2543
self_range .end = args_range .end = parser -> current_token .range .end ;
2544
2544
}
@@ -2611,7 +2611,7 @@ static bool parse_module_members(rbs_parser_t *parser, rbs_node_list_t **members
2611
2611
case tA2IDENT :
2612
2612
case kATRBS :
2613
2613
case kSELF : {
2614
- TypeValidation validation = { .no_void = true };
2614
+ rbs_type_validation_t validation = { .no_void = true };
2615
2615
if (parser -> current_token .type == tA2IDENT ) {
2616
2616
validation .no_self = true;
2617
2617
}
@@ -2784,7 +2784,7 @@ static bool parse_class_decl_super(rbs_parser_t *parser, rbs_range_t *lt_range,
2784
2784
& name_range ,
2785
2785
& args_range ,
2786
2786
& name ,
2787
- (TypeValidation ) { .no_void = true, .no_void_allowed_here = true, .no_self = true, .no_classish = true }
2787
+ (rbs_type_validation_t ) { .no_void = true, .no_void_allowed_here = true, .no_self = true, .no_classish = true }
2788
2788
));
2789
2789
2790
2790
super_range .end = parser -> current_token .range .end ;
0 commit comments