|
64 | 64 | case kRETURN: \ |
65 | 65 | /* nop */ |
66 | 66 |
|
| 67 | +#define PARAM_NAME_CASES \ |
| 68 | +case kBOOL:\ |
| 69 | +case kBOT: \ |
| 70 | +case kCLASS: \ |
| 71 | +case kFALSE: \ |
| 72 | +case kINSTANCE: \ |
| 73 | +case kINTERFACE: \ |
| 74 | +case kNIL: \ |
| 75 | +case kSELF: \ |
| 76 | +case kSINGLETON: \ |
| 77 | +case kTOP: \ |
| 78 | +case kTRUE: \ |
| 79 | +case kVOID: \ |
| 80 | +case kTYPE: \ |
| 81 | +case kUNCHECKED: \ |
| 82 | +case kIN: \ |
| 83 | +case kOUT: \ |
| 84 | +case kEND: \ |
| 85 | +case kDEF: \ |
| 86 | +case kINCLUDE: \ |
| 87 | +case kEXTEND: \ |
| 88 | +case kPREPEND: \ |
| 89 | +case kALIAS: \ |
| 90 | +case kMODULE: \ |
| 91 | +case kATTRREADER: \ |
| 92 | +case kATTRWRITER: \ |
| 93 | +case kATTRACCESSOR: \ |
| 94 | +case kPUBLIC: \ |
| 95 | +case kPRIVATE: \ |
| 96 | +case kUNTYPED: \ |
| 97 | +case kUSE: \ |
| 98 | +case kAS: \ |
| 99 | +case k__TODO__: \ |
| 100 | +/* nop */ |
| 101 | + |
67 | 102 | #define CHECK_PARSE(call) \ |
68 | 103 | if (!call) { \ |
69 | 104 | return false; \ |
@@ -3541,6 +3576,49 @@ static bool parse_inline_comment(rbs_parser_t *parser, rbs_location_t **comment) |
3541 | 3576 | return true; |
3542 | 3577 | } |
3543 | 3578 |
|
| 3579 | +NODISCARD |
| 3580 | +static bool parse_inline_param_type_annotation(rbs_parser_t *parser, rbs_ast_ruby_annotations_t **annotation, rbs_range_t rbs_range) { |
| 3581 | + rbs_parser_advance(parser); |
| 3582 | + |
| 3583 | + rbs_range_t name_range = parser->current_token.range; |
| 3584 | + rbs_location_t *name_loc = rbs_location_new(ALLOCATOR(), name_range); |
| 3585 | + |
| 3586 | + ADVANCE_ASSERT(parser, pCOLON); |
| 3587 | + |
| 3588 | + rbs_range_t colon_range = parser->current_token.range; |
| 3589 | + rbs_location_t *colon_loc = rbs_location_new(ALLOCATOR(), colon_range); |
| 3590 | + |
| 3591 | + rbs_node_t *param_type = NULL; |
| 3592 | + if (!rbs_parse_type(parser, ¶m_type)) { |
| 3593 | + return false; |
| 3594 | + } |
| 3595 | + |
| 3596 | + rbs_location_t *comment_loc = NULL; |
| 3597 | + if (!parse_inline_comment(parser, &comment_loc)) { |
| 3598 | + return false; |
| 3599 | + } |
| 3600 | + |
| 3601 | + rbs_range_t full_range = { |
| 3602 | + .start = rbs_range.start, |
| 3603 | + .end = parser->current_token.range.end |
| 3604 | + }; |
| 3605 | + |
| 3606 | + rbs_location_t *full_loc = rbs_location_new(ALLOCATOR(), full_range); |
| 3607 | + rbs_location_t *rbs_loc = rbs_location_new(ALLOCATOR(), rbs_range); |
| 3608 | + |
| 3609 | + *annotation = (rbs_ast_ruby_annotations_t *) rbs_ast_ruby_annotations_param_type_annotation_new( |
| 3610 | + ALLOCATOR(), |
| 3611 | + full_loc, |
| 3612 | + rbs_loc, |
| 3613 | + name_loc, |
| 3614 | + colon_loc, |
| 3615 | + param_type, |
| 3616 | + comment_loc |
| 3617 | + ); |
| 3618 | + |
| 3619 | + return true; |
| 3620 | +} |
| 3621 | + |
3544 | 3622 | NODISCARD |
3545 | 3623 | static bool parse_inline_leading_annotation(rbs_parser_t *parser, rbs_ast_ruby_annotations_t **annotation) { |
3546 | 3624 | switch (parser->next_token.type) { |
@@ -3673,6 +3751,11 @@ static bool parse_inline_leading_annotation(rbs_parser_t *parser, rbs_ast_ruby_a |
3673 | 3751 | ); |
3674 | 3752 | return true; |
3675 | 3753 | } |
| 3754 | + case tLIDENT: |
| 3755 | + PARAM_NAME_CASES |
| 3756 | + { |
| 3757 | + return parse_inline_param_type_annotation(parser, annotation, rbs_range); |
| 3758 | + } |
3676 | 3759 | default: { |
3677 | 3760 | rbs_parser_set_error(parser, parser->next_token, true, "unexpected token for @rbs annotation"); |
3678 | 3761 | return false; |
|
0 commit comments