8000 Rename TypeValidation to rbs_type_validation_t to follow naming conve… · ruby/rbs@8f5dda9 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 8f5dda9

Browse files
committed
Rename TypeValidation to rbs_type_validation_t to follow naming convention
1 parent 18a2b16 commit 8f5dda9

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

include/rbs/parser.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,23 +127,23 @@ rbs_ast_comment_t *rbs_parser_get_comment(rbs_parser_t *parser, int subject_line
127127
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

129129
/**
130-
* TypeValidation represents the validation rules for type parsing.
130+
* rbs_type_validation_t represents the validation rules for type parsing.
131131
* It controls whether certain types are allowed in specific contexts.
132132
* */
133133
typedef struct {
134134
bool no_void; /* If true, `void` type is not allowed.*/
135135
bool no_void_allowed_here; /* If true, `void` type is not allowed, but it's allowed in one depth.*/
136136
bool no_self; /* If true, `self` type is not allowed.*/
137137
bool no_classish; /* If true, `class` or `instance` types are not allowed.*/
138-
} TypeValidation;
138+
} rbs_type_validation_t;
139139

140140
/**
141-
* SkipValidation is a TypeValidation that allows all types.
141+
* SkipValidation is a rbs_type_validation_t that allows all types.
142142
* */
143-
extern const TypeValidation SkipValidation;
143+
extern const rbs_type_validation_t SkipValidation;
144144

145-
bool rbs_parse_type(rbs_parser_t *parser, rbs_node_t **type, TypeValidation validation);
146-
bool rbs_parse_method_type(rbs_parser_t *parser, rbs_method_type_t **method_type, TypeValidation validation);
145+
bool rbs_parse_type(rbs_parser_t *parser, rbs_node_t **type, rbs_type_validation_t validation);
146+
bool rbs_parse_method_type(rbs_parser_t *parser, rbs_method_type_t **method_type, rbs_type_validation_t validation);
147147
bool rbs_parse_signature(rbs_parser_t *parser, rbs_signature_t **signature);
148148

149149
bool rbs_parse_type_params(rbs_parser_t *parser, bool module_type_params, rbs_node_list_t **params);

src/parser.c

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ typedef struct id_table {
106106
struct id_table *next;
107107
} id_table;
108108

109-
const TypeValidation SkipValidation = {
109+
const rbs_type_validation_t SkipValidation = {
110110
.no_void = false,
111111
.no_void_allowed_here = false,
112112
.no_self = false,
@@ -127,8 +127,8 @@ static rbs_location_t *rbs_location_current_token(rbs_parser_t *parser) {
127127
return rbs_location_new(ALLOCATOR(), parser->current_token.range);
128128
}
129129

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);
132132

133133
/**
134134
* @returns A borrowed copy of the current token, which does *not* need to be freed.
@@ -251,7 +251,7 @@ error_handling: {
251251
| {} type `,` ... `,` <type> eol
252252
*/
253253
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) {
255255
while (true) {
256256
rbs_node_t *type;
257257
CHECK_PARSE(rbs_parse_type(parser, &type, validation));
@@ -296,7 +296,7 @@ static bool is_keyword_token(enum RBSTokenType type) {
296296
| {} type <param>
297297
*/
298298
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) {
300300
rbs_range_t type_range;
301301
type_range.start = parser->next_token.range.start;
302302
rbs_node_t *type;
@@ -464,7 +464,7 @@ static bool parser_advance_if(rbs_parser_t *parser, enum RBSTokenType type) {
464464
| {} `**` <function_param>
465465
*/
466466
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) {
468468
if (parser->next_token.type == pQUESTION && parser->next_token2.type == pRPAREN) {
469469
params->required_positionals = NULL;
470470
rbs_parser_advance(parser);
@@ -630,7 +630,7 @@ static bool parse_params(rbs_parser_t *parser, method_params *params, TypeValida
630630
| {} simple_type <`?`>
631631
*/
632632
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) {
634634
rbs_range_t rg;
635635
rg.start = parser->next_token.range.start;
636636

@@ -666,7 +666,7 @@ static void initialize_method_params(method_params *params, rbs_allocator_t *all
666666
| {} `[` `self` `:` type <`]`>
667667
*/
668668
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) {
670670
if (parser->next_token.type == pLBRACKET) {
671671
rbs_parser_advance(parser);
672672
ADVANCE_ASSERT(parser, kSELF);
@@ -694,13 +694,13 @@ typedef struct {
694694
| {} self_type_binding? `->` <optional>
695695
*/
696696
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) {
698698
rbs_node_t *function = NULL;
699699
rbs_types_block_t *block = NULL;
700700
rbs_node_t *function_self_type = NULL;
701701
rbs_range_t function_range;
702702
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;
704704
no_void_allowed_here.no_void_allowed_here = true;
705705

706706
method_params params;
@@ -814,7 +814,7 @@ static bool parse_function(rbs_parser_t *parser, bool accept_type_binding, parse
814814
proc_type ::= {`^`} <function>
815815
*/
816816
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) {
818818
rbs_position_t start = parser->current_token.range.start;
819819
parse_function_result *result = rbs_allocator_alloc(ALLOCATOR(), parse_function_result);
820820
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_
842842
| {} literal_type `=>` <type>
843843
*/
844844
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) {
846846
*fields = rbs_hash_new(ALLOCATOR());
847847

848848
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
999999
if (parser->next_token.type == pLBRACKET) {
10001000
rbs_parser_advance(parser);
10011001
args_range.start = parser->current_token.range.start;
1002-
TypeValidation no_void_allowed_here = {
1002+
rbs_type_validation_t no_void_allowed_here = {
10031003
.no_void = false,
10041004
.no_void_allowed_here = true,
10051005
.no_self = false,
@@ -1092,7 +1092,7 @@ static bool parser_typevar_member(rbs_parser_t *parser, rbs_constant_id_t id) {
10921092
| {} `^` <function>
10931093
*/
10941094
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) {
10961096
rbs_parser_advance(parser);
10971097

10981098
if (parser->current_token.type != kVOID) {
@@ -1289,7 +1289,7 @@ static bool parse_simple(rbs_parser_t *parser, rbs_node_t **type, TypeValidation
12891289
| {} <optional>
12901290
*/
12911291
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) {
12931293
rbs_range_t rg;
12941294
rg.start = parser->next_token.range.start;
12951295

@@ -1321,7 +1321,7 @@ static bool parse_intersection(rbs_parser_t *parser, rbs_node_t **type, TypeVali
13211321
union ::= {} intersection '|' ... '|' <intersection>
13221322
| {} <intersection>
13231323
*/
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) {
13251325
rbs_range_t rg;
13261326
rg.start = parser->next_token.range.start;
13271327
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
14161416
if (parser->next_token.type == pLT) {
14171417
rbs_parser_advance(parser);
14181418
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 }));
14201420
upper_bound_range.end = parser->current_token.range.end;
14211421
}
14221422

@@ -1426,7 +1426,7 @@ static bool parse_type_params(rbs_parser_t *parser, rbs_range_t *rg, bool module
14261426
rbs_parser_advance(parser);
14271427

14281428
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 }));
14301430
default_type_range.end = parser->current_token.range.end;
14311431

14321432
required_param_allowed = false;
@@ -1494,7 +1494,7 @@ static bool parser_pop_typevar_table(rbs_parser_t *parser) {
14941494
method_type ::= {} type_params <function>
14951495
*/
14961496
// 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) {
14981498
rbs_parser_push_typevar_table(parser, false);
14991499

15001500
rbs_range_t rg;
@@ -1543,7 +1543,7 @@ static bool parse_global_decl(rbs_parser_t *parser, rbs_node_list_t *annotations
15431543
rbs_range_t colon_range = parser->current_token.range;
15441544

15451545
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 }));
15471547
decl_range.end = parser->current_token.range.end;
15481548

15491549
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,
15731573
rbs_range_t colon_range = parser->current_token.range;
15741574

15751575
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 }));
15771577

15781578
decl_range.end = parser->current_token.range.end;
15791579

@@ -1613,7 +1613,7 @@ static bool parse_type_decl(rbs_parser_t *parser, rbs_position_t comment_pos, rb
16131613
rbs_range_t eq_range = parser->current_token.range;
16141614

16151615
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 }));
16171617

16181618
decl_range.end = parser->current_token.range.end;
16191619

@@ -1921,7 +1921,7 @@ static bool parse_member_def(rbs_parser_t *parser, bool instance_only, bool acce
19211921
case pLBRACKET:
19221922
case pQUESTION: {
19231923
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 }));
19251925

19261926
overload_range.end = parser->current_token.range.end;
19271927
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
19961996
* @param kind
19971997
* */
19981998
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) {
20002000
rbs_parser_advance(parser);
20012001

20022002
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
20682068
&name_range,
20692069
&args_range,
20702070
&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 }
20722072
));
20732073

20742074
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
21602160
| {tA2IDENT} `:` <type>
21612161
*/
21622162
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) {
21642164
if (annotations->length > 0) {
21652165
rbs_parser_set_error(parser, parser->current_token, true, "annotation cannot be given to variable members");
21662166
return false;
@@ -2385,7 +2385,7 @@ static bool parse_attribute_member(rbs_parser_t *parser, rbs_position_t comment_
23852385
rbs_parser_push_typevar_table(parser, is_kind == SINGLETON_KIND);
23862386

23872387
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 }));
23892389

23902390
CHECK_PARSE(parser_pop_typevar_table(parser));
23912391

@@ -2538,7 +2538,7 @@ static bool parse_module_self_types(rbs_parser_t *parser, rbs_node_list_t *array
25382538
if (parser->next_token.type == pLBRACKET) {
25392539
rbs_parser_advance(parser);
25402540
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 }));
25422542
rbs_parser_advance(parser);
25432543
self_range.end = args_range.end = parser->current_token.range.end;
25442544
}
@@ -2611,7 +2611,7 @@ static bool parse_module_members(rbs_parser_t *parser, rbs_node_list_t **members
26112611
case tA2IDENT:
26122612
case kATRBS:
26132613
case kSELF: {
2614-
TypeValidation validation = { .no_void = true };
2614+
rbs_type_validation_t validation = { .no_void = true };
26152615
if (parser->current_token.type == tA2IDENT) {
26162616
validation.no_self = true;
26172617
}
@@ -2784,7 +2784,7 @@ static bool parse_class_decl_super(rbs_parser_t *parser, rbs_range_t *lt_range,
27842784
&name_range,
27852785
&args_range,
27862786
&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 }
27882788
));
27892789

27902790
super_range.end = parser->current_token.range.end;

0 commit comments

Comments
 (0)
0