diff --git a/ext/rbs_extension/constants.c b/ext/rbs_extension/constants.c index 57ec73ee3..e4f04832a 100644 --- a/ext/rbs_extension/constants.c +++ b/ext/rbs_extension/constants.c @@ -40,6 +40,7 @@ VALUE RBS_AST_Members_MethodDefinition; VALUE RBS_AST_Members_MethodDefinition_Overload; VALUE RBS_AST_Members_Prepend; VALUE RBS_AST_Members_Private; +VALUE RBS_AST_Members_Protected; VALUE RBS_AST_Members_Public; VALUE RBS_Namespace; @@ -118,6 +119,7 @@ void rbs__init_constants(void) { IMPORT_CONSTANT(RBS_AST_Members_MethodDefinition_Overload, RBS_AST_Members_MethodDefinition, "Overload"); IMPORT_CONSTANT(RBS_AST_Members_Prepend, RBS_AST_Members, "Prepend"); IMPORT_CONSTANT(RBS_AST_Members_Private, RBS_AST_Members, "Private"); + IMPORT_CONSTANT(RBS_AST_Members_Protected, RBS_AST_Members, "Protected"); IMPORT_CONSTANT(RBS_AST_Members_Public, RBS_AST_Members, "Public"); IMPORT_CONSTANT(RBS_Namespace, RBS, "Namespace"); diff --git a/ext/rbs_extension/constants.h b/ext/rbs_extension/constants.h index 978bc32d0..a05bf15cd 100644 --- a/ext/rbs_extension/constants.h +++ b/ext/rbs_extension/constants.h @@ -39,6 +39,7 @@ extern VALUE RBS_AST_Members_MethodDefinition; extern VALUE RBS_AST_Members_MethodDefinition_Overload; extern VALUE RBS_AST_Members_Prepend; extern VALUE RBS_AST_Members_Private; +extern VALUE RBS_AST_Members_Protected; extern VALUE RBS_AST_Members_Public; extern VALUE RBS_MethodType; diff --git a/ext/rbs_extension/lexer.c b/ext/rbs_extension/lexer.c index 040d537a0..f555bac7d 100644 --- a/ext/rbs_extension/lexer.c +++ b/ext/rbs_extension/lexer.c @@ -1,5 +1,5 @@ -/* Generated by re2c 3.1 */ -#line 1 "ext/rbs_extension/lexer.re" +/* Generated by re2c 3.1 on Fri Feb 9 14:01:57 2024 */ +#line 1 "lexer.re" #include "rbs_extension.h" token rbsparser_next_token(lexstate *state) { @@ -9,7 +9,7 @@ token rbsparser_next_token(lexstate *state) { backup = *state; -#line 13 "ext/rbs_extension/lexer.c" +#line 13 "" { unsigned int yych; unsigned int yyaccept = 0; @@ -116,15 +116,15 @@ token rbsparser_next_token(lexstate *state) { } yy1: rbs_skip(state); -#line 145 "ext/rbs_extension/lexer.re" +#line 146 "lexer.re" { return next_token(state, pEOF); } -#line 122 "ext/rbs_extension/lexer.c" +#line 122 "" yy2: rbs_skip(state); yy3: -#line 146 "ext/rbs_extension/lexer.re" +#line 147 "lexer.re" { return next_token(state, ErrorToken); } -#line 128 "ext/rbs_extension/lexer.c" +#line 128 "" yy4: rbs_skip(state); yych = peek(state); @@ -136,18 +136,18 @@ token rbsparser_next_token(lexstate *state) { if (yych == ' ') goto yy4; } yy5: -#line 144 "ext/rbs_extension/lexer.re" +#line 145 "lexer.re" { state->start = state->current; goto start; } -#line 142 "ext/rbs_extension/lexer.c" +#line 142 "" yy6: rbs_skip(state); yych = peek(state); if (yych == '=') goto yy23; if (yych == '~') goto yy23; yy7: -#line 49 "ext/rbs_extension/lexer.re" +#line 49 "lexer.re" { return next_token(state, tOPERATOR); } -#line 151 "ext/rbs_extension/lexer.c" +#line 151 "" yy8: yyaccept = 0; rbs_skip(state); @@ -161,14 +161,14 @@ token rbsparser_next_token(lexstate *state) { if (yych <= 0x00000000) goto yy10; if (yych != '\n') goto yy9; yy10: -#line 60 "ext/rbs_extension/lexer.re" +#line 60 "lexer.re" { return next_token( state, state->first_token_of_line ? tLINECOMMENT : tCOMMENT ); } -#line 172 "ext/rbs_extension/lexer.c" +#line 172 "" yy11: rbs_skip(state); yych = peek(state); @@ -224,9 +224,9 @@ token rbsparser_next_token(lexstate *state) { goto yy7; yy13: rbs_skip(state); -#line 34 "ext/rbs_extension/lexer.re" +#line 34 "lexer.re" { return next_token(state, pAMP); } -#line 230 "ext/rbs_extension/lexer.c" +#line 230 "" yy14: yyaccept = 0; rbs_skip(state); @@ -236,21 +236,21 @@ token rbsparser_next_token(lexstate *state) { goto yy75; yy15: rbs_skip(state); -#line 25 "ext/rbs_extension/lexer.re" +#line 25 "lexer.re" { return next_token(state, pLPAREN); } -#line 242 "ext/rbs_extension/lexer.c" +#line 242 "" yy16: rbs_skip(state); -#line 26 "ext/rbs_extension/lexer.re" +#line 26 "lexer.re" { return next_token(state, pRPAREN); } -#line 247 "ext/rbs_extension/lexer.c" +#line 247 "" yy17: rbs_skip(state); yych = peek(state); if (yych == '*') goto yy79; -#line 36 "ext/rbs_extension/lexer.re" +#line 36 "lexer.re" { return next_token(state, pSTAR); } -#line 254 "ext/rbs_extension/lexer.c" +#line 254 "" yy18: rbs_skip(state); yych = peek(state); @@ -260,9 +260,9 @@ token rbsparser_next_token(lexstate *state) { goto yy7; yy19: rbs_skip(state); -#line 31 "ext/rbs_extension/lexer.re" +#line 31 "lexer.re" { return next_token(state, pCOMMA); } -#line 266 "ext/rbs_extension/lexer.c" +#line 266 "" yy20: rbs_skip(state); yych = peek(state); @@ -282,9 +282,9 @@ token rbsparser_next_token(lexstate *state) { yych = peek(state); if (yych == '.') goto yy81; yy22: -#line 38 "ext/rbs_extension/lexer.re" +#line 38 "lexer.re" { return next_token(state, pDOT); } -#line 288 "ext/rbs_extension/lexer.c" +#line 288 "" yy23: rbs_skip(state); goto yy7; @@ -295,9 +295,9 @@ token rbsparser_next_token(lexstate *state) { if (yych <= '9') goto yy24; if (yych == '_') goto yy24; yy25: -#line 52 "ext/rbs_extension/lexer.re" +#line 52 "lexer.re" { return next_token(state, tINTEGER); } -#line 301 "ext/rbs_extension/lexer.c" +#line 301 "" yy26: yyaccept = 3; rbs_skip(state); @@ -380,9 +380,9 @@ token rbsparser_next_token(lexstate *state) { default: goto yy27; } yy27: -#line 45 "ext/rbs_extension/lexer.re" +#line 45 "lexer.re" { return next_token(state, pCOLON); } -#line 386 "ext/rbs_extension/lexer.c" +#line 386 "" yy28: rbs_skip(state); yych = peek(state); @@ -390,9 +390,9 @@ token rbsparser_next_token(lexstate *state) { if (yych <= '<') goto yy23; if (yych <= '=') goto yy98; yy29: -#line 47 "ext/rbs_extension/lexer.re" +#line 47 "lexer.re" { return next_token(state, pLT); } -#line 396 "ext/rbs_extension/lexer.c" +#line 396 "" yy30: rbs_skip(state); yych = peek(state); @@ -404,9 +404,9 @@ token rbsparser_next_token(lexstate *state) { if (yych == '~') goto yy23; } yy31: -#line 44 "ext/rbs_extension/lexer.re" +#line 44 "lexer.re" { return next_token(state, pEQ); } -#line 410 "ext/rbs_extension/lexer.c" +#line 410 "" yy32: rbs_skip(state); yych = peek(state); @@ -415,9 +415,9 @@ token rbsparser_next_token(lexstate *state) { goto yy7; yy33: rbs_skip(state); -#line 35 "ext/rbs_extension/lexer.re" +#line 35 "lexer.re" { return next_token(state, pQUESTION); } -#line 421 "ext/rbs_extension/lexer.c" +#line 421 "" yy34: yyaccept = 0; rbs_skip(state); @@ -453,26 +453,26 @@ token rbsparser_next_token(lexstate *state) { } } yy36: -#line 130 "ext/rbs_extension/lexer.re" +#line 131 "lexer.re" { return next_token(state, tUIDENT); } -#line 459 "ext/rbs_extension/lexer.c" +#line 459 "" yy37: rbs_skip(state); yych = peek(state); if (yych == ']') goto yy106; -#line 27 "ext/rbs_extension/lexer.re" +#line 27 "lexer.re" { return next_token(state, pLBRACKET); } -#line 466 "ext/rbs_extension/lexer.c" +#line 466 "" yy38: rbs_skip(state); -#line 28 "ext/rbs_extension/lexer.re" +#line 28 "lexer.re" { return next_token(state, pRBRACKET); } -#line 471 "ext/rbs_extension/lexer.c" +#line 471 "" yy39: rbs_skip(state); -#line 33 "ext/rbs_extension/lexer.re" +#line 33 "lexer.re" { return next_token(state, pHAT); } -#line 476 "ext/rbs_extension/lexer.c" +#line 476 "" yy40: rbs_skip(state); yych = peek(state); @@ -494,9 +494,9 @@ token rbsparser_next_token(lexstate *state) { } } yy41: -#line 133 "ext/rbs_extension/lexer.re" +#line 134 "lexer.re" { return next_token(state, tULLIDENT); } -#line 500 "ext/rbs_extension/lexer.c" +#line 500 "" yy42: yyaccept = 4; rbs_skip(state); @@ -509,9 +509,9 @@ token rbsparser_next_token(lexstate *state) { if (yych != ':') goto yy113; } yy43: -#line 40 "ext/rbs_extension/lexer.re" +#line 40 "lexer.re" { return next_token(state, tOPERATOR); } -#line 515 "ext/rbs_extension/lexer.c" +#line 515 "" yy44: rbs_skip(state); yych = peek(state); @@ -524,9 +524,9 @@ token rbsparser_next_token(lexstate *state) { goto yy52; } yy45: -#line 129 "ext/rbs_extension/lexer.re" +#line 130 "lexer.re" { return next_token(state, tLIDENT); } -#line 530 "ext/rbs_extension/lexer.c" +#line 530 "" yy46: rbs_skip(state); yych = peek(state); @@ -633,19 +633,19 @@ token rbsparser_next_token(lexstate *state) { goto yy52; yy62: rbs_skip(state); -#line 29 "ext/rbs_extension/lexer.re" +#line 29 "lexer.re" { return next_token(state, pLBRACE); } -#line 639 "ext/rbs_extension/lexer.c" +#line 639 "" yy63: rbs_skip(state); -#line 32 "ext/rbs_extension/lexer.re" +#line 32 "lexer.re" { return next_token(state, pBAR); } -#line 644 "ext/rbs_extension/lexer.c" +#line 644 "" yy64: rbs_skip(state); -#line 30 "ext/rbs_extension/lexer.re" +#line 30 "lexer.re" { return next_token(state, pRBRACE); } -#line 649 "ext/rbs_extension/lexer.c" +#line 649 "" yy65: rbs_skip(state); yych = peek(state); @@ -687,9 +687,9 @@ token rbsparser_next_token(lexstate *state) { } yy68: rbs_skip(state); -#line 107 "ext/rbs_extension/lexer.re" +#line 108 "lexer.re" { return next_token(state, tDQSTRING); } -#line 693 "ext/rbs_extension/lexer.c" +#line 693 "" yy69: rbs_skip(state); yych = peek(state); @@ -726,9 +726,9 @@ token rbsparser_next_token(lexstate *state) { } } yy71: -#line 140 "ext/rbs_extension/lexer.re" +#line 141 "lexer.re" { return next_token(state, tGIDENT); } -#line 732 "ext/rbs_extension/lexer.c" +#line 732 "" yy72: rbs_skip(state); goto yy71; @@ -767,9 +767,9 @@ token rbsparser_next_token(lexstate *state) { yy76: rbs_skip(state); yy77: -#line 108 "ext/rbs_extension/lexer.re" +#line 109 "lexer.re" { return next_token(state, tSQSTRING); } -#line 773 "ext/rbs_extension/lexer.c" +#line 773 "" yy78: rbs_skip(state); yych = peek(state); @@ -783,14 +783,14 @@ token rbsparser_next_token(lexstate *state) { } yy79: rbs_skip(state); -#line 37 "ext/rbs_extension/lexer.re" +#line 37 "lexer.re" { return next_token(state, pSTAR2); } -#line 789 "ext/rbs_extension/lexer.c" +#line 789 "" yy80: rbs_skip(state); -#line 42 "ext/rbs_extension/lexer.re" +#line 42 "lexer.re" { return next_token(state, pARROW); } -#line 794 "ext/rbs_extension/lexer.c" +#line 794 "" yy81: rbs_skip(state); yych = peek(state); @@ -802,9 +802,9 @@ token rbsparser_next_token(lexstate *state) { if (yych == '=') goto yy86; if (yych == '~') goto yy86; yy83: -#line 127 "ext/rbs_extension/lexer.re" +#line 128 "lexer.re" { return next_token(state, tSYMBOL); } -#line 808 "ext/rbs_extension/lexer.c" +#line 808 "" yy84: rbs_skip(state); yych = peek(state); @@ -888,9 +888,9 @@ token rbsparser_next_token(lexstate *state) { goto yy83; yy90: rbs_skip(state); -#line 46 "ext/rbs_extension/lexer.re" +#line 46 "lexer.re" { return next_token(state, pCOLON2); } -#line 894 "ext/rbs_extension/lexer.c" +#line 894 "" yy91: rbs_skip(state); yych = peek(state); @@ -944,9 +944,9 @@ token rbsparser_next_token(lexstate *state) { } } yy96: -#line 123 "ext/rbs_extension/lexer.re" +#line 124 "lexer.re" { return next_token(state, tSYMBOL); } -#line 950 "ext/rbs_extension/lexer.c" +#line 950 "" yy97: rbs_skip(state); yych = peek(state); @@ -964,9 +964,9 @@ token rbsparser_next_token(lexstate *state) { goto yy7; yy100: rbs_skip(state); -#line 43 "ext/rbs_extension/lexer.re" +#line 43 "lexer.re" { return next_token(state, pFATARROW); } -#line 970 "ext/rbs_extension/lexer.c" +#line 970 "" yy101: rbs_skip(state); yych = peek(state); @@ -995,26 +995,26 @@ token rbsparser_next_token(lexstate *state) { } } yy103: -#line 137 "ext/rbs_extension/lexer.re" +#line 138 "lexer.re" { return next_token(state, tAIDENT); } -#line 1001 "ext/rbs_extension/lexer.c" +#line 1001 "" yy104: rbs_skip(state); -#line 134 "ext/rbs_extension/lexer.re" +#line 135 "lexer.re" { return next_token(state, tBANGIDENT); } -#line 1006 "ext/rbs_extension/lexer.c" +#line 1006 "" yy105: rbs_skip(state); -#line 135 "ext/rbs_extension/lexer.re" +#line 136 "lexer.re" { return next_token(state, tEQIDENT); } -#line 1011 "ext/rbs_extension/lexer.c" +#line 1011 "" yy106: rbs_skip(state); yych = peek(state); if (yych == '=') goto yy23; -#line 48 "ext/rbs_extension/lexer.re" +#line 48 "lexer.re" { return next_token(state, pAREF_OPR); } -#line 1018 "ext/rbs_extension/lexer.c" +#line 1018 "" yy107: rbs_skip(state); yych = peek(state); @@ -1036,9 +1036,9 @@ token rbsparser_next_token(lexstate *state) { } } yy109: -#line 131 "ext/rbs_extension/lexer.re" +#line 132 "lexer.re" { return next_token(state, tULLIDENT); } -#line 1042 "ext/rbs_extension/lexer.c" +#line 1042 "" yy110: rbs_skip(state); yych = peek(state); @@ -1059,9 +1059,9 @@ token rbsparser_next_token(lexstate *state) { } } yy111: -#line 132 "ext/rbs_extension/lexer.re" +#line 133 "lexer.re" { return next_token(state, tULIDENT); } -#line 1065 "ext/rbs_extension/lexer.c" +#line 1065 "" yy112: rbs_skip(state); yych = peek(state); @@ -1098,9 +1098,9 @@ token rbsparser_next_token(lexstate *state) { } } yy116: -#line 97 "ext/rbs_extension/lexer.re" +#line 98 "lexer.re" { return next_token(state, kAS); } -#line 1104 "ext/rbs_extension/lexer.c" +#line 1104 "" yy117: rbs_skip(state); yych = peek(state); @@ -1168,9 +1168,9 @@ token rbsparser_next_token(lexstate *state) { } } yy125: -#line 78 "ext/rbs_extension/lexer.re" +#line 78 "lexer.re" { return next_token(state, kIN); } -#line 1174 "ext/rbs_extension/lexer.c" +#line 1174 "" yy126: rbs_skip(state); yych = peek(state); @@ -1189,66 +1189,71 @@ token rbsparser_next_token(lexstate *state) { yy129: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy186; - if (yych == 'i') goto yy187; - goto yy52; + if (yych <= 'h') { + if (yych == 'e') goto yy186; + goto yy52; + } else { + if (yych <= 'i') goto yy187; + if (yych == 'o') goto yy188; + goto yy52; + } yy130: rbs_skip(state); yych = peek(state); - if (yych == 'b') goto yy188; + if (yych == 'b') goto yy189; goto yy52; yy131: rbs_skip(state); yych = peek(state); - if (yych == 'l') goto yy189; + if (yych == 'l') goto yy190; goto yy52; yy132: rbs_skip(state); yych = peek(state); - if (yych == 'n') goto yy190; + if (yych == 'n') goto yy191; goto yy52; yy133: rbs_skip(state); yych = peek(state); - if (yych == 'p') goto yy191; + if (yych == 'p') goto yy192; goto yy52; yy134: rbs_skip(state); yych = peek(state); - if (yych == 'u') goto yy193; + if (yych == 'u') goto yy194; goto yy52; yy135: rbs_skip(state); yych = peek(state); - if (yych == 'p') goto yy194; + if (yych == 'p') goto yy195; goto yy52; yy136: rbs_skip(state); yych = peek(state); - if (yych == 'c') goto yy195; - if (yych == 't') goto yy196; + if (yych == 'c') goto yy196; + if (yych == 't') goto yy197; goto yy52; yy137: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy197; + if (yych == 'e') goto yy198; goto yy52; yy138: rbs_skip(state); yych = peek(state); - if (yych == 'i') goto yy199; + if (yych == 'i') goto yy200; goto yy52; yy139: rbs_skip(state); yych = peek(state); if (yych <= '@') { if (yych <= '/') goto yy67; - if (yych <= '9') goto yy200; + if (yych <= '9') goto yy201; goto yy67; } else { - if (yych <= 'F') goto yy200; + if (yych <= 'F') goto yy201; if (yych <= '`') goto yy67; - if (yych <= 'f') goto yy200; + if (yych <= 'f') goto yy201; goto yy67; } yy140: @@ -1263,31 +1268,31 @@ token rbsparser_next_token(lexstate *state) { rbs_skip(state); yych = peek(state); if (yych <= 0x00000000) goto yy67; - if (yych == ')') goto yy201; + if (yych == ')') goto yy202; goto yy141; yy142: rbs_skip(state); yych = peek(state); if (yych <= 0x00000000) goto yy67; - if (yych == '>') goto yy202; + if (yych == '>') goto yy203; goto yy142; yy143: rbs_skip(state); yych = peek(state); if (yych <= 0x00000000) goto yy67; - if (yych == ']') goto yy203; + if (yych == ']') goto yy204; goto yy143; yy144: rbs_skip(state); yych = peek(state); if (yych <= 0x00000000) goto yy67; - if (yych == '}') goto yy204; + if (yych == '}') goto yy205; goto yy144; yy145: rbs_skip(state); yych = peek(state); if (yych <= 0x00000000) goto yy67; - if (yych == '|') goto yy205; + if (yych == '|') goto yy206; goto yy145; yy146: yyaccept = 5; @@ -1304,19 +1309,19 @@ token rbsparser_next_token(lexstate *state) { } yy147: rbs_skip(state); -#line 39 "ext/rbs_extension/lexer.re" +#line 39 "lexer.re" { return next_token(state, pDOT3); } -#line 1310 "ext/rbs_extension/lexer.c" +#line 1315 "" yy148: rbs_skip(state); -#line 109 "ext/rbs_extension/lexer.re" +#line 110 "lexer.re" { return next_token(state, tDQSYMBOL); } -#line 1315 "ext/rbs_extension/lexer.c" +#line 1320 "" yy149: rbs_skip(state); yych = peek(state); - if (yych == 'u') goto yy206; - if (yych == 'x') goto yy207; + if (yych == 'u') goto yy207; + if (yych == 'x') goto yy208; goto yy84; yy150: rbs_skip(state); @@ -1348,25 +1353,25 @@ token rbsparser_next_token(lexstate *state) { } } yy151: -#line 126 "ext/rbs_extension/lexer.re" +#line 127 "lexer.re" { return next_token(state, tSYMBOL); } -#line 1354 "ext/rbs_extension/lexer.c" +#line 1359 "" yy152: rbs_skip(state); goto yy151; yy153: rbs_skip(state); yy154: -#line 110 "ext/rbs_extension/lexer.re" +#line 111 "lexer.re" { return next_token(state, tSQSYMBOL); } -#line 1363 "ext/rbs_extension/lexer.c" +#line 1368 "" yy155: rbs_skip(state); yych = peek(state); if (yych <= '\'') { if (yych <= 0x00000000) goto yy67; if (yych <= '&') goto yy87; - goto yy208; + goto yy209; } else { if (yych == '\\') goto yy155; goto yy87; @@ -1386,11 +1391,11 @@ token rbsparser_next_token(lexstate *state) { yych = peek(state); if (yych <= '^') { if (yych <= '@') goto yy67; - if (yych <= 'Z') goto yy209; + if (yych <= 'Z') goto yy210; goto yy67; } else { if (yych == '`') goto yy67; - if (yych <= 'z') goto yy209; + if (yych <= 'z') goto yy210; goto yy67; } yy159: @@ -1398,14 +1403,14 @@ token rbsparser_next_token(lexstate *state) { yych = peek(state); if (yych <= '>') { if (yych <= '/') { - if (yych == '!') goto yy211; + if (yych == '!') goto yy212; } else { if (yych <= '9') goto yy159; - if (yych == '=') goto yy211; + if (yych == '=') goto yy212; } } else { if (yych <= '^') { - if (yych <= '?') goto yy211; + if (yych <= '?') goto yy212; if (yych <= '@') goto yy160; if (yych <= 'Z') goto yy159; } else { @@ -1414,9 +1419,9 @@ token rbsparser_next_token(lexstate *state) { } } yy160: -#line 124 "ext/rbs_extension/lexer.re" +#line 125 "lexer.re" { return next_token(state, tSYMBOL); } -#line 1420 "ext/rbs_extension/lexer.c" +#line 1425 "" yy161: rbs_skip(state); goto yy96; @@ -1436,33 +1441,33 @@ token rbsparser_next_token(lexstate *state) { } } yy163: -#line 138 "ext/rbs_extension/lexer.re" +#line 139 "lexer.re" { return next_token(state, tA2IDENT); } -#line 1442 "ext/rbs_extension/lexer.c" +#line 1447 "" yy164: rbs_skip(state); yych = peek(state); - if (yych == 'o') goto yy212; + if (yych == 'o') goto yy213; goto yy108; yy165: rbs_skip(state); -#line 41 "ext/rbs_extension/lexer.re" +#line 41 "lexer.re" { return next_token(state, tQIDENT); } -#line 1452 "ext/rbs_extension/lexer.c" +#line 1457 "" yy166: rbs_skip(state); yych = peek(state); - if (yych == 'a') goto yy213; + if (yych == 'a') goto yy214; goto yy52; yy167: rbs_skip(state); yych = peek(state); - if (yych == 'r') goto yy214; + if (yych == 'r') goto yy215; goto yy52; yy168: rbs_skip(state); yych = peek(state); - if (yych == 'l') goto yy215; + if (yych == 'l') goto yy216; goto yy52; yy169: rbs_skip(state); @@ -1484,13 +1489,13 @@ token rbsparser_next_token(lexstate *state) { } } yy170: -#line 72 "ext/rbs_extension/lexer.re" +#line 72 "lexer.re" { return next_token(state, kBOT); } -#line 1490 "ext/rbs_extension/lexer.c" +#line 1495 "" yy171: rbs_skip(state); yych = peek(state); - if (yych == 's') goto yy217; + if (yych == 's') goto yy218; goto yy52; yy172: rbs_skip(state); @@ -1512,9 +1517,9 @@ token rbsparser_next_token(lexstate *state) { } } yy173: -#line 74 "ext/rbs_extension/lexer.re" +#line 74 "lexer.re" { return next_token(state, kDEF); } -#line 1518 "ext/rbs_extension/lexer.c" +#line 1523 "" yy174: rbs_skip(state); yych = peek(state); @@ -1535,38 +1540,38 @@ token rbsparser_next_token(lexstate *state) { } } yy175: -#line 75 "ext/rbs_extension/lexer.re" +#line 75 "lexer.re" { return next_token(state, kEND); } -#line 1541 "ext/rbs_extension/lexer.c" +#line 1546 "" yy176: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy218; + if (yych == 'e') goto yy219; goto yy52; yy177: rbs_skip(state); yych = peek(state); - if (yych == 's') goto yy219; + if (yych == 's') goto yy220; goto yy52; yy178: rbs_skip(state); yych = peek(state); - if (yych == 'l') goto yy220; + if (yych == 'l') goto yy221; goto yy52; yy179: rbs_skip(state); yych = peek(state); - if (yych == 't') goto yy221; + if (yych == 't') goto yy222; goto yy52; yy180: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy222; + if (yych == 'e') goto yy223; goto yy52; yy181: rbs_skip(state); yych = peek(state); - if (yych == 'u') goto yy223; + if (yych == 'u') goto yy224; goto yy52; yy182: rbs_skip(state); @@ -1588,9 +1593,9 @@ token rbsparser_next_token(lexstate *state) { } } yy183: -#line 83 "ext/rbs_extension/lexer.re" +#line 83 "lexer.re" { return next_token(state, kNIL); } -#line 1594 "ext/rbs_extension/lexer.c" +#line 1599 "" yy184: rbs_skip(state); yych = peek(state); @@ -1611,35 +1616,40 @@ token rbsparser_next_token(lexstate *state) { } } yy185: -#line 84 "ext/rbs_extension/lexer.re" +#line 84 "lexer.re" { return next_token(state, kOUT); } -#line 1617 "ext/rbs_extension/lexer.c" +#line 1622 "" yy186: rbs_skip(state); yych = peek(state); - if (yych == 'p') goto yy224; + if (yych == 'p') goto yy225; goto yy52; yy187: rbs_skip(state); yych = peek(state); - if (yych == 'v') goto yy225; + if (yych == 'v') goto yy226; goto yy52; yy188: rbs_skip(state); yych = peek(state); - if (yych == 'l') goto yy226; + if (yych == 't') goto yy227; goto yy52; yy189: rbs_skip(state); yych = peek(state); - if (yych == 'f') goto yy227; + if (yych == 'l') goto yy228; goto yy52; yy190: rbs_skip(state); yych = peek(state); - if (yych == 'g') goto yy229; + if (yych == 'f') goto yy229; goto yy52; yy191: + rbs_skip(state); + yych = peek(state); + if (yych == 'g') goto yy231; + goto yy52; +yy192: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -1651,22 +1661,17 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy192; + if (yych <= '@') goto yy193; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy192; + if (yych == '`') goto yy193; if (yych <= 'z') goto yy51; } } -yy192: -#line 90 "ext/rbs_extension/lexer.re" - { return next_token(state, kTOP); } -#line 1665 "ext/rbs_extension/lexer.c" yy193: - rbs_skip(state); - yych = peek(state); - if (yych == 'e') goto yy230; - goto yy52; +#line 91 "lexer.re" + { return next_token(state, kTOP); } +#line 1675 "" yy194: rbs_skip(state); yych = peek(state); @@ -1675,14 +1680,19 @@ token rbsparser_next_token(lexstate *state) { yy195: rbs_skip(state); yych = peek(state); - if (yych == 'h') goto yy234; + if (yych == 'e') goto yy234; goto yy52; yy196: rbs_skip(state); yych = peek(state); - if (yych == 'y') goto yy235; + if (yych == 'h') goto yy236; goto yy52; yy197: + rbs_skip(state); + yych = peek(state); + if (yych == 'y') goto yy237; + goto yy52; +yy198: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -1694,74 +1704,74 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy198; + if (yych <= '@') goto yy199; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy198; + if (yych == '`') goto yy199; if (yych <= 'z') goto yy51; } } -yy198: -#line 96 "ext/rbs_extension/lexer.re" - { return next_token(state, kUSE); } -#line 1708 "ext/rbs_extension/lexer.c" yy199: +#line 97 "lexer.re" + { return next_token(state, kUSE); } +#line 1718 "" +yy200: rbs_skip(state); yych = peek(state); - if (yych == 'd') goto yy236; + if (yych == 'd') goto yy238; goto yy52; -yy200: +yy201: rbs_skip(state); yych = peek(state); if (yych <= '@') { if (yych <= '/') goto yy67; - if (yych <= '9') goto yy238; + if (yych <= '9') goto yy240; goto yy67; } else { - if (yych <= 'F') goto yy238; + if (yych <= 'F') goto yy240; if (yych <= '`') goto yy67; - if (yych <= 'f') goto yy238; + if (yych <= 'f') goto yy240; goto yy67; } -yy201: - rbs_skip(state); -#line 55 "ext/rbs_extension/lexer.re" - { return next_token(state, tANNOTATION); } -#line 1731 "ext/rbs_extension/lexer.c" yy202: rbs_skip(state); -#line 58 "ext/rbs_extension/lexer.re" +#line 55 "lexer.re" { return next_token(state, tANNOTATION); } -#line 1736 "ext/rbs_extension/lexer.c" +#line 1741 "" yy203: rbs_skip(state); -#line 56 "ext/rbs_extension/lexer.re" +#line 58 "lexer.re" { return next_token(state, tANNOTATION); } -#line 1741 "ext/rbs_extension/lexer.c" +#line 1746 "" yy204: rbs_skip(state); -#line 54 "ext/rbs_extension/lexer.re" +#line 56 "lexer.re" { return next_token(state, tANNOTATION); } -#line 1746 "ext/rbs_extension/lexer.c" +#line 1751 "" yy205: rbs_skip(state); -#line 57 "ext/rbs_extension/lexer.re" +#line 54 "lexer.re" { return next_token(state, tANNOTATION); } -#line 1751 "ext/rbs_extension/lexer.c" +#line 1756 "" yy206: rbs_skip(state); +#line 57 "lexer.re" + { return next_token(state, tANNOTATION); } +#line 1761 "" +yy207: + rbs_skip(state); yych = peek(state); if (yych <= '@') { if (yych <= '/') goto yy67; - if (yych <= '9') goto yy239; + if (yych <= '9') goto yy241; goto yy67; } else { - if (yych <= 'F') goto yy239; + if (yych <= 'F') goto yy241; if (yych <= '`') goto yy67; - if (yych <= 'f') goto yy239; + if (yych <= 'f') goto yy241; goto yy67; } -yy207: +yy208: rbs_skip(state); yych = peek(state); if (yych <= '/') goto yy67; @@ -1769,7 +1779,7 @@ token rbsparser_next_token(lexstate *state) { if (yych <= '`') goto yy67; if (yych <= 'f') goto yy84; goto yy67; -yy208: +yy209: yyaccept = 6; rbs_skip(state); backup = *state; @@ -1782,49 +1792,49 @@ token rbsparser_next_token(lexstate *state) { if (yych == '\\') goto yy155; goto yy87; } -yy209: +yy210: rbs_skip(state); yych = peek(state); if (yych <= '>') { if (yych <= '/') { - if (yych == '!') goto yy240; + if (yych == '!') goto yy242; } else { - if (yych <= '9') goto yy209; - if (yych == '=') goto yy240; + if (yych <= '9') goto yy210; + if (yych == '=') goto yy242; } } else { if (yych <= '^') { - if (yych <= '?') goto yy240; - if (yych <= '@') goto yy210; - if (yych <= 'Z') goto yy209; + if (yych <= '?') goto yy242; + if (yych <= '@') goto yy211; + if (yych <= 'Z') goto yy210; } else { - if (yych == '`') goto yy210; - if (yych <= 'z') goto yy209; + if (yych == '`') goto yy211; + if (yych <= 'z') goto yy210; } } -yy210: -#line 125 "ext/rbs_extension/lexer.re" - { return next_token(state, tSYMBOL); } -#line 1809 "ext/rbs_extension/lexer.c" yy211: +#line 126 "lexer.re" + { return next_token(state, tSYMBOL); } +#line 1819 "" +yy212: rbs_skip(state); goto yy160; -yy212: +yy213: rbs_skip(state); yych = peek(state); - if (yych == 'd') goto yy241; + if (yych == 'd') goto yy243; goto yy108; -yy213: +yy214: rbs_skip(state); yych = peek(state); - if (yych == 's') goto yy242; + if (yych == 's') goto yy244; goto yy52; -yy214: +yy215: rbs_skip(state); yych = peek(state); - if (yych == '_') goto yy244; + if (yych == '_') goto yy246; goto yy52; -yy215: +yy216: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -1836,68 +1846,73 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy216; + if (yych <= '@') goto yy217; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy216; + if (yych == '`') goto yy217; if (yych <= 'z') goto yy51; } } -yy216: -#line 71 "ext/rbs_extension/lexer.re" - { return next_token(state, kBOOL); } -#line 1850 "ext/rbs_extension/lexer.c" yy217: - rbs_skip(state); - yych = peek(state); - if (yych == 's') goto yy245; - goto yy52; +#line 71 "lexer.re" + { return next_token(state, kBOOL); } +#line 1860 "" yy218: rbs_skip(state); yych = peek(state); - if (yych == 'n') goto yy247; + if (yych == 's') goto yy247; goto yy52; yy219: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy248; + if (yych == 'n') goto yy249; goto yy52; yy220: rbs_skip(state); yych = peek(state); - if (yych == 'u') goto yy250; + if (yych == 'e') goto yy250; goto yy52; yy221: rbs_skip(state); yych = peek(state); - if (yych == 'a') goto yy251; + if (yych == 'u') goto yy252; goto yy52; yy222: rbs_skip(state); yych = peek(state); - if (yych == 'r') goto yy252; + if (yych == 'a') goto yy253; goto yy52; yy223: rbs_skip(state); yych = peek(state); - if (yych == 'l') goto yy253; + if (yych == 'r') goto yy254; goto yy52; yy224: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy254; + if (yych == 'l') goto yy255; goto yy52; yy225: rbs_skip(state); yych = peek(state); - if (yych == 'a') goto yy255; + if (yych == 'e') goto yy256; goto yy52; yy226: rbs_skip(state); yych = peek(state); - if (yych == 'i') goto yy256; + if (yych == 'a') goto yy257; goto yy52; yy227: + rbs_skip(state); + yych = peek(state); + if (yych == 'e') goto yy258; + goto yy52; +yy228: + rbs_skip(state); + yych = peek(state); + if (yych == 'i') goto yy259; + goto yy52; +yy229: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -1909,23 +1924,23 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy228; + if (yych <= '@') goto yy230; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy228; + if (yych == '`') goto yy230; if (yych <= 'z') goto yy51; } } -yy228: -#line 88 "ext/rbs_extension/lexer.re" +yy230: +#line 89 "lexer.re" { return next_token(state, kSELF); } -#line 1923 "ext/rbs_extension/lexer.c" -yy229: +#line 1938 "" +yy231: rbs_skip(state); yych = peek(state); - if (yych == 'l') goto yy257; + if (yych == 'l') goto yy260; goto yy52; -yy230: +yy232: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -1937,18 +1952,18 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy231; + if (yych <= '@') goto yy233; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy231; + if (yych == '`') goto yy233; if (yych <= 'z') goto yy51; } } -yy231: -#line 91 "ext/rbs_extension/lexer.re" +yy233: +#line 92 "lexer.re" { return next_token(state, kTRUE); } -#line 1951 "ext/rbs_extension/lexer.c" -yy232: +#line 1966 "" +yy234: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -1960,28 +1975,28 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy233; + if (yych <= '@') goto yy235; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy233; + if (yych == '`') goto yy235; if (yych <= 'z') goto yy51; } } -yy233: -#line 92 "ext/rbs_extension/lexer.re" +yy235: +#line 93 "lexer.re" { return next_token(state, kTYPE); } -#line 1974 "ext/rbs_extension/lexer.c" -yy234: +#line 1989 "" +yy236: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy258; + if (yych == 'e') goto yy261; goto yy52; -yy235: +yy237: rbs_skip(state); yych = peek(state); - if (yych == 'p') goto yy259; + if (yych == 'p') goto yy262; goto yy52; -yy236: +yy238: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -1993,52 +2008,52 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy237; + if (yych <= '@') goto yy239; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy237; + if (yych == '`') goto yy239; if (yych <= 'z') goto yy51; } } -yy237: -#line 95 "ext/rbs_extension/lexer.re" +yy239: +#line 96 "lexer.re" { return next_token(state, kVOID); } -#line 2007 "ext/rbs_extension/lexer.c" -yy238: +#line 2022 "" +yy240: rbs_skip(state); yych = peek(state); if (yych <= '@') { if (yych <= '/') goto yy67; - if (yych <= '9') goto yy260; + if (yych <= '9') goto yy263; goto yy67; } else { - if (yych <= 'F') goto yy260; + if (yych <= 'F') goto yy263; if (yych <= '`') goto yy67; - if (yych <= 'f') goto yy260; + if (yych <= 'f') goto yy263; goto yy67; } -yy239: +yy241: rbs_skip(state); yych = peek(state); if (yych <= '@') { if (yych <= '/') goto yy67; - if (yych <= '9') goto yy261; + if (yych <= '9') goto yy264; goto yy67; } else { - if (yych <= 'F') goto yy261; + if (yych <= 'F') goto yy264; if (yych <= '`') goto yy67; - if (yych <= 'f') goto yy261; + if (yych <= 'f') goto yy264; goto yy67; } -yy240: +yy242: rbs_skip(state); - goto yy210; -yy241: + goto yy211; +yy243: rbs_skip(state); yych = peek(state); - if (yych == 'o') goto yy262; + if (yych == 'o') goto yy265; goto yy108; -yy242: +yy244: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2050,29 +2065,29 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy243; + if (yych <= '@') goto yy245; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy243; + if (yych == '`') goto yy245; if (yych <= 'z') goto yy51; } } -yy243: -#line 67 "ext/rbs_extension/lexer.re" +yy245: +#line 67 "lexer.re" { return next_token(state, kALIAS); } -#line 2064 "ext/rbs_extension/lexer.c" -yy244: +#line 2079 "" +yy246: rbs_skip(state); yych = peek(state); if (yych <= 'q') { - if (yych == 'a') goto yy263; + if (yych == 'a') goto yy266; goto yy52; } else { - if (yych <= 'r') goto yy264; - if (yych == 'w') goto yy265; + if (yych <= 'r') goto yy267; + if (yych == 'w') goto yy268; goto yy52; } -yy245: +yy247: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2084,23 +2099,23 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy246; + if (yych <= '@') goto yy248; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy246; + if (yych == '`') goto yy248; if (yych <= 'z') goto yy51; } } -yy246: -#line 73 "ext/rbs_extension/lexer.re" +yy248: +#line 73 "lexer.re" { return next_token(state, kCLASS); } -#line 2098 "ext/rbs_extension/lexer.c" -yy247: +#line 2113 "" +yy249: rbs_skip(state); yych = peek(state); - if (yych == 'd') goto yy266; + if (yych == 'd') goto yy269; goto yy52; -yy248: +yy250: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2112,56 +2127,46 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy249; + if (yych <= '@') goto yy251; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy249; + if (yych == '`') goto yy251; if (yych <= 'z') goto yy51; } } -yy249: -#line 77 "ext/rbs_extension/lexer.re" - { return next_token(state, kFALSE); } -#line 2126 "ext/rbs_extension/lexer.c" -yy250: - rbs_skip(state); - yych = peek(state); - if (yych == 'd') goto yy268; - goto yy52; yy251: - rbs_skip(state); - yych = peek(state); - if (yych == 'n') goto yy269; - goto yy52; +#line 77 "lexer.re" + { return next_token(state, kFALSE); } +#line 2141 "" yy252: rbs_skip(state); yych = peek(state); - if (yych == 'f') goto yy270; + if (yych == 'd') goto yy271; goto yy52; yy253: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy271; + if (yych == 'n') goto yy272; goto yy52; yy254: rbs_skip(state); yych = peek(state); - if (yych == 'n') goto yy273; + if (yych == 'f') goto yy273; goto yy52; yy255: rbs_skip(state); yych = peek(state); - if (yych == 't') goto yy274; + if (yych == 'e') goto yy274; goto yy52; yy256: rbs_skip(state); yych = peek(state); - if (yych == 'c') goto yy275; + if (yych == 'n') goto yy276; goto yy52; yy257: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy277; + if (yych == 't') goto yy277; goto yy52; yy258: rbs_skip(state); @@ -2171,9 +2176,24 @@ token rbsparser_next_token(lexstate *state) { yy259: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy279; + if (yych == 'c') goto yy279; goto yy52; yy260: + rbs_skip(state); + yych = peek(state); + if (yych == 'e') goto yy281; + goto yy52; +yy261: + rbs_skip(state); + yych = peek(state); + if (yych == 'c') goto yy282; + goto yy52; +yy262: + rbs_skip(state); + yych = peek(state); + if (yych == 'e') goto yy283; + goto yy52; +yy263: rbs_skip(state); yych = peek(state); if (yych <= '@') { @@ -2186,40 +2206,40 @@ token rbsparser_next_token(lexstate *state) { if (yych <= 'f') goto yy65; goto yy67; } -yy261: +yy264: rbs_skip(state); yych = peek(state); if (yych <= '@') { if (yych <= '/') goto yy67; - if (yych <= '9') goto yy280; + if (yych <= '9') goto yy284; goto yy67; } else { - if (yych <= 'F') goto yy280; + if (yych <= 'F') goto yy284; if (yych <= '`') goto yy67; - if (yych <= 'f') goto yy280; + if (yych <= 'f') goto yy284; goto yy67; } -yy262: +yy265: rbs_skip(state); yych = peek(state); - if (yych == '_') goto yy281; + if (yych == '_') goto yy285; goto yy108; -yy263: +yy266: rbs_skip(state); yych = peek(state); - if (yych == 'c') goto yy282; + if (yych == 'c') goto yy286; goto yy52; -yy264: +yy267: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy283; + if (yych == 'e') goto yy287; goto yy52; -yy265: +yy268: rbs_skip(state); yych = peek(state); - if (yych == 'r') goto yy284; + if (yych == 'r') goto yy288; goto yy52; -yy266: +yy269: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2231,33 +2251,33 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy267; + if (yych <= '@') goto yy270; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy267; + if (yych == '`') goto yy270; if (yych <= 'z') goto yy51; } } -yy267: -#line 76 "ext/rbs_extension/lexer.re" +yy270: +#line 76 "lexer.re" { return next_token(state, kEXTEND); } -#line 2245 "ext/rbs_extension/lexer.c" -yy268: +#line 2265 "" +yy271: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy285; + if (yych == 'e') goto yy289; goto yy52; -yy269: +yy272: rbs_skip(state); yych = peek(state); - if (yych == 'c') goto yy287; + if (yych == 'c') goto yy291; goto yy52; -yy270: +yy273: rbs_skip(state); yych = peek(state); - if (yych == 'a') goto yy288; + if (yych == 'a') goto yy292; goto yy52; -yy271: +yy274: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2269,28 +2289,33 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy272; + if (yych <= '@') goto yy275; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy272; + if (yych == '`') goto yy275; if (yych <= 'z') goto yy51; } } -yy272: -#line 82 "ext/rbs_extension/lexer.re" +yy275: +#line 82 "lexer.re" { return next_token(state, kMODULE); } -#line 2283 "ext/rbs_extension/lexer.c" -yy273: +#line 2303 "" +yy276: rbs_skip(state); yych = peek(state); - if (yych == 'd') goto yy289; + if (yych == 'd') goto yy293; goto yy52; -yy274: +yy277: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy291; + if (yych == 'e') goto yy295; goto yy52; -yy275: +yy278: + rbs_skip(state); + yych = peek(state); + if (yych == 't') goto yy297; + goto yy52; +yy279: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2302,33 +2327,33 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy276; + if (yych <= '@') goto yy280; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy276; + if (yych == '`') goto yy280; if (yych <= 'z') goto yy51; } } -yy276: -#line 87 "ext/rbs_extension/lexer.re" +yy280: +#line 88 "lexer.re" { return next_token(state, kPUBLIC); } -#line 2316 "ext/rbs_extension/lexer.c" -yy277: +#line 2341 "" +yy281: rbs_skip(state); yych = peek(state); - if (yych == 't') goto yy293; + if (yych == 't') goto yy298; goto yy52; -yy278: +yy282: rbs_skip(state); yych = peek(state); - if (yych == 'k') goto yy294; + if (yych == 'k') goto yy299; goto yy52; -yy279: +yy283: rbs_skip(state); yych = peek(state); - if (yych == 'd') goto yy295; + if (yych == 'd') goto yy300; goto yy52; -yy280: +yy284: rbs_skip(state); yych = peek(state); if (yych <= '@') { @@ -2341,27 +2366,27 @@ token rbsparser_next_token(lexstate *state) { if (yych <= 'f') goto yy84; goto yy67; } -yy281: +yy285: rbs_skip(state); yych = peek(state); - if (yych == '_') goto yy297; + if (yych == '_') goto yy302; goto yy108; -yy282: +yy286: rbs_skip(state); yych = peek(state); - if (yych == 'c') goto yy299; + if (yych == 'c') goto yy304; goto yy52; -yy283: +yy287: rbs_skip(state); yych = peek(state); - if (yych == 'a') goto yy300; + if (yych == 'a') goto yy305; goto yy52; -yy284: +yy288: rbs_skip(state); yych = peek(state); - if (yych == 'i') goto yy301; + if (yych == 'i') goto yy306; goto yy52; -yy285: +yy289: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2373,28 +2398,28 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy286; + if (yych <= '@') goto yy290; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy286; + if (yych == '`') goto yy290; if (yych <= 'z') goto yy51; } } -yy286: -#line 79 "ext/rbs_extension/lexer.re" +yy290: +#line 79 "lexer.re" { return next_token(state, kINCLUDE); } -#line 2387 "ext/rbs_extension/lexer.c" -yy287: +#line 2412 "" +yy291: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy302; + if (yych == 'e') goto yy307; goto yy52; -yy288: +yy292: rbs_skip(state); yych = peek(state); - if (yych == 'c') goto yy304; + if (yych == 'c') goto yy309; goto yy52; -yy289: +yy293: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2406,18 +2431,18 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy290; + if (yych <= '@') goto yy294; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy290; + if (yych == '`') goto yy294; if (yych <= 'z') goto yy51; } } -yy290: -#line 85 "ext/rbs_extension/lexer.re" +yy294: +#line 85 "lexer.re" { return next_token(state, kPREPEND); } -#line 2420 "ext/rbs_extension/lexer.c" -yy291: +#line 2445 "" +yy295: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2429,28 +2454,33 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy292; + if (yych <= '@') goto yy296; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy292; + if (yych == '`') goto yy296; if (yych <= 'z') goto yy51; } } -yy292: -#line 86 "ext/rbs_extension/lexer.re" +yy296: +#line 86 "lexer.re" { return next_token(state, kPRIVATE); } -#line 2443 "ext/rbs_extension/lexer.c" -yy293: +#line 2468 "" +yy297: rbs_skip(state); yych = peek(state); - if (yych == 'o') goto yy305; + if (yych == 'e') goto yy310; goto yy52; -yy294: +yy298: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy306; + if (yych == 'o') goto yy311; goto yy52; -yy295: +yy299: + rbs_skip(state); + yych = peek(state); + if (yych == 'e') goto yy312; + goto yy52; +yy300: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2462,18 +2492,18 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy296; + if (yych <= '@') goto yy301; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy296; + if (yych == '`') goto yy301; if (yych <= 'z') goto yy51; } } -yy296: -#line 94 "ext/rbs_extension/lexer.re" +yy301: +#line 95 "lexer.re" { return next_token(state, kUNTYPED); } -#line 2476 "ext/rbs_extension/lexer.c" -yy297: +#line 2506 "" +yy302: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2485,33 +2515,33 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy298; + if (yych <= '@') goto yy303; if (yych <= 'Z') goto yy107; } else { - if (yych == '`') goto yy298; + if (yych == '`') goto yy303; if (yych <= 'z') goto yy107; } } -yy298: -#line 98 "ext/rbs_extension/lexer.re" +yy303: +#line 99 "lexer.re" { return next_token(state, k__TODO__); } -#line 2499 "ext/rbs_extension/lexer.c" -yy299: +#line 2529 "" +yy304: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy307; + if (yych == 'e') goto yy313; goto yy52; -yy300: +yy305: rbs_skip(state); yych = peek(state); - if (yych == 'd') goto yy308; + if (yych == 'd') goto yy314; goto yy52; -yy301: +yy306: rbs_skip(state); yych = peek(state); - if (yych == 't') goto yy309; + if (yych == 't') goto yy315; goto yy52; -yy302: +yy307: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2523,48 +2553,53 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy303; + if (yych <= '@') goto yy308; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy303; + if (yych == '`') goto yy308; if (yych <= 'z') goto yy51; } } -yy303: -#line 80 "ext/rbs_extension/lexer.re" +yy308: +#line 80 "lexer.re" { return next_token(state, kINSTANCE); } -#line 2537 "ext/rbs_extension/lexer.c" -yy304: +#line 2567 "" +yy309: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy310; + if (yych == 'e') goto yy316; goto yy52; -yy305: +yy310: rbs_skip(state); yych = peek(state); - if (yych == 'n') goto yy312; + if (yych == 'd') goto yy318; goto yy52; -yy306: +yy311: rbs_skip(state); yych = peek(state); - if (yych == 'd') goto yy314; + if (yych == 'n') goto yy320; goto yy52; -yy307: +yy312: rbs_skip(state); yych = peek(state); - if (yych == 's') goto yy316; + if (yych == 'd') goto yy322; goto yy52; -yy308: +yy313: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy317; + if (yych == 's') goto yy324; goto yy52; -yy309: +yy314: rbs_skip(state); yych = peek(state); - if (yych == 'e') goto yy318; + if (yych == 'e') goto yy325; goto yy52; -yy310: +yy315: + rbs_skip(state); + yych = peek(state); + if (yych == 'e') goto yy326; + goto yy52; +yy316: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2576,18 +2611,18 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy311; + if (yych <= '@') goto yy317; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy311; + if (yych == '`') goto yy317; if (yych <= 'z') goto yy51; } } -yy311: -#line 81 "ext/rbs_extension/lexer.re" +yy317: +#line 81 "lexer.re" { return next_token(state, kINTERFACE); } -#line 2590 "ext/rbs_extension/lexer.c" -yy312: +#line 2625 "" +yy318: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2599,18 +2634,41 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy313; + if (yych <= '@') goto yy319; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy313; + if (yych == '`') goto yy319; if (yych <= 'z') goto yy51; } } -yy313: -#line 89 "ext/rbs_extension/lexer.re" +yy319: +#line 87 "lexer.re" + { return next_token(state, kPROTECTED); } +#line 2648 "" +yy320: + rbs_skip(state); + yych = peek(state); + if (yych <= '=') { + if (yych <= '/') { + if (yych == '!') goto yy104; + } else { + if (yych <= '9') goto yy51; + if (yych >= '=') goto yy105; + } + } else { + if (yych <= '^') { + if (yych <= '@') goto yy321; + if (yych <= 'Z') goto yy51; + } else { + if (yych == '`') goto yy321; + if (yych <= 'z') goto yy51; + } + } +yy321: +#line 90 "lexer.re" { return next_token(state, kSINGLETON); } -#line 2613 "ext/rbs_extension/lexer.c" -yy314: +#line 2671 "" +yy322: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2622,38 +2680,38 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy315; + if (yych <= '@') goto yy323; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy315; + if (yych == '`') goto yy323; if (yych <= 'z') goto yy51; } } -yy315: -#line 93 "ext/rbs_extension/lexer.re" +yy323: +#line 94 "lexer.re" { return next_token(state, kUNCHECKED); } -#line 2636 "ext/rbs_extension/lexer.c" -yy316: +#line 2694 "" +yy324: rbs_skip(state); yych = peek(state); - if (yych == 's') goto yy319; + if (yych == 's') goto yy327; goto yy52; -yy317: +yy325: rbs_skip(state); yych = peek(state); - if (yych == 'r') goto yy320; + if (yych == 'r') goto yy328; goto yy52; -yy318: +yy326: rbs_skip(state); yych = peek(state); - if (yych == 'r') goto yy322; + if (yych == 'r') goto yy330; goto yy52; -yy319: +yy327: rbs_skip(state); yych = peek(state); - if (yych == 'o') goto yy324; + if (yych == 'o') goto yy332; goto yy52; -yy320: +yy328: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2665,18 +2723,18 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy321; + if (yych <= '@') goto yy329; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy321; + if (yych == '`') goto yy329; if (yych <= 'z') goto yy51; } } -yy321: -#line 69 "ext/rbs_extension/lexer.re" +yy329: +#line 69 "lexer.re" { return next_token(state, kATTRREADER); } -#line 2679 "ext/rbs_extension/lexer.c" -yy322: +#line 2737 "" +yy330: rbs_skip(state); yych = peek(state); if (yych <= '=') { @@ -2688,18 +2746,18 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy323; + if (yych <= '@') goto yy331; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy323; + if (yych == '`') goto yy331; if (yych <= 'z') goto yy51; } } -yy323: -#line 70 "ext/rbs_extension/lexer.re" +yy331: +#line 70 "lexer.re" { return next_token(state, kATTRWRITER); } -#line 2702 "ext/rbs_extension/lexer.c" -yy324: +#line 2760 "" +yy332: rbs_skip(state); yych = peek(state); if (yych != 'r') goto yy52; @@ -2714,18 +2772,18 @@ token rbsparser_next_token(lexstate *state) { } } else { if (yych <= '^') { - if (yych <= '@') goto yy325; + if (yych <= '@') goto yy333; if (yych <= 'Z') goto yy51; } else { - if (yych == '`') goto yy325; + if (yych == '`') goto yy333; if (yych <= 'z') goto yy51; } } -yy325: -#line 68 "ext/rbs_extension/lexer.re" +yy333: +#line 68 "lexer.re" { return next_token(state, kATTRACCESSOR); } -#line 2728 "ext/rbs_extension/lexer.c" +#line 2786 "" } -#line 147 "ext/rbs_extension/lexer.re" +#line 148 "lexer.re" } diff --git a/ext/rbs_extension/lexer.h b/ext/rbs_extension/lexer.h index 9e4228d81..fbc2be5a9 100644 --- a/ext/rbs_extension/lexer.h +++ b/ext/rbs_extension/lexer.h @@ -49,6 +49,7 @@ enum TokenType { kOUT, /* out */ kPREPEND, /* prepend */ kPRIVATE, /* private */ + kPROTECTED, /* protected */ kPUBLIC, /* public */ kSELF, /* self */ kSINGLETON, /* singleton */ diff --git a/ext/rbs_extension/lexer.re b/ext/rbs_extension/lexer.re index 1547f96f6..65a0b409a 100644 --- a/ext/rbs_extension/lexer.re +++ b/ext/rbs_extension/lexer.re @@ -84,6 +84,7 @@ start: "out" { return next_token(state, kOUT); } "prepend" { return next_token(state, kPREPEND); } "private" { return next_token(state, kPRIVATE); } + "protected" { return next_token(state, kPROTECTED); } "public" { return next_token(state, kPUBLIC); } "self" { return next_token(state, kSELF); } "singleton" { return next_token(state, kSINGLETON); } diff --git a/ext/rbs_extension/lexstate.c b/ext/rbs_extension/lexstate.c index 0f7c2f454..3d96bb700 100644 --- a/ext/rbs_extension/lexstate.c +++ b/ext/rbs_extension/lexstate.c @@ -48,6 +48,7 @@ static const char *RBS_TOKENTYPE_NAMES[] = { "kOUT", /* out */ "kPREPEND", /* prepend */ "kPRIVATE", /* private */ + "kPROTECTED", /* protected */ "kPUBLIC", /* public */ "kSELF", /* self */ "kSINGLETON", /* singleton */ diff --git a/ext/rbs_extension/parser.c b/ext/rbs_extension/parser.c index 15400209e..1d48fd31b 100644 --- a/ext/rbs_extension/parser.c +++ b/ext/rbs_extension/parser.c @@ -36,6 +36,7 @@ case kATTRACCESSOR: \ case kPUBLIC: \ case kPRIVATE: \ + case kPROTECTED: \ case kUNTYPED: \ case kUSE: \ case kAS: \ @@ -1495,6 +1496,7 @@ InstanceSingletonKind parse_instance_singleton_kind(parserstate *state, bool all * def_member ::= {kDEF} method_name `:` * | {kPRIVATE} kDEF method_name `:` * | {kPUBLIC} kDEF method_name `:` + * | {kPROTECTED} kDEF method_name `:` * * method_types ::= {} * | {} <`...`> @@ -1531,6 +1533,12 @@ VALUE parse_member_def(parserstate *state, bool instance_only, bool accept_overl member_range.start = visibility_range.start; parser_advance(state); break; + case kPROTECTED: + visibility_range = state->current_token.range; + visibility = ID2SYM(rb_intern("protected")); + member_range.start = visibility_range.start; + parser_advance(state); + break; default: visibility_range = NULL_RANGE; visibility = Qnil; @@ -1915,6 +1923,7 @@ VALUE parse_variable_member(parserstate *state, position comment_pos, VALUE anno /* visibility_member ::= {<`public`>} | {<`private`>} + | {<`protected`>} */ VALUE parse_visibility_member(parserstate *state, VALUE annotations) { if (rb_array_len(annotations) > 0) { @@ -1935,6 +1944,9 @@ VALUE parse_visibility_member(parserstate *state, VALUE annotations) { case kPRIVATE: klass = RBS_AST_Members_Private; break; + case kPROTECTED: + klass = RBS_AST_Members_Protected; + break; default: rbs_abort(); } @@ -1953,7 +1965,7 @@ VALUE parse_visibility_member(parserstate *state, VALUE annotations) { attr_keyword ::= `attr_reader` | `attr_writer` | `attr_accessor` - visibility ::= `public` | `private` + visibility ::= `public` | `private` | `protected` attr_var ::= # empty | `(` tAIDENT `)` # Ivar name @@ -1991,6 +2003,11 @@ VALUE parse_attribute_member(parserstate *state, position comment_pos, VALUE ann visibility_range = state->current_token.range; parser_advance(state); break; + case kPROTECTED: + visibility = ID2SYM(rb_intern("protected")); + visibility_range = state->current_token.range; + parser_advance(state); + break; default: visibility = Qnil; visibility_range = NULL_RANGE; @@ -2217,6 +2234,7 @@ VALUE parse_nested_decl(parserstate *state, const char *nested_in, position anno | attribute_member | `public` | `private` + | `protected` */ VALUE parse_module_members(parserstate *state) { VALUE members = rb_ary_new(); @@ -2260,6 +2278,7 @@ VALUE parse_module_members(parserstate *state) { case kPUBLIC: case kPRIVATE: + case kPROTECTED: if (state->next_token.range.start.line == state->current_token.range.start.line) { switch (state->next_token.type) { diff --git a/lib/rbs/ast/members.rb b/lib/rbs/ast/members.rb index 7888a1686..15eb6561b 100644 --- a/lib/rbs/ast/members.rb +++ b/lib/rbs/ast/members.rb @@ -394,6 +394,14 @@ def to_json(state = _ = nil) end end + class Protected < Base + include LocationOnly + + def to_json(state = _ = nil) + { member: :protected, location: location }.to_json(state) + end + end + class Alias < Base attr_reader :new_name attr_reader :old_name diff --git a/lib/rbs/definition.rb b/lib/rbs/definition.rb index 307a6e89e..83ce6834b 100644 --- a/lib/rbs/definition.rb +++ b/lib/rbs/definition.rb @@ -139,6 +139,14 @@ def private? @accessibility == :private end + def protected? + @accessibility == :protected + end + + def undef? + @accessibility == :undef + end + def sub(s) self.class.new( super_method: super_method&.sub(s), diff --git a/lib/rbs/definition_builder/method_builder.rb b/lib/rbs/definition_builder/method_builder.rb index f137aed4e..1e8721792 100644 --- a/lib/rbs/definition_builder/method_builder.rb +++ b/lib/rbs/definition_builder/method_builder.rb @@ -230,6 +230,8 @@ def each_member_with_accessibility(members, accessibility: :public) accessibility = :public when AST::Members::Private accessibility = :private + when AST::Members::Protected + accessibility = :protected else yield member, accessibility end diff --git a/lib/rbs/parser_aux.rb b/lib/rbs/parser_aux.rb index a243e7697..75a9065e1 100644 --- a/lib/rbs/parser_aux.rb +++ b/lib/rbs/parser_aux.rb @@ -60,6 +60,7 @@ def self.buffer(source) attr_accessor public private + protected untyped true false diff --git a/lib/rbs/prototype/rb.rb b/lib/rbs/prototype/rb.rb index d6d78dd64..3784d0b1a 100644 --- a/lib/rbs/prototype/rb.rb +++ b/lib/rbs/prototype/rb.rb @@ -761,6 +761,11 @@ def public @public ||= AST::Members::Public.new(location: nil) end + def protected + @protected ||= AST::Members::Public.new(location: nil) + end + + # TODO def current_accessibility(decls, index = decls.size) slice = decls.slice(0, index) or raise idx = slice.rindex { |decl| decl == private || decl == public } diff --git a/lib/rbs/sorter.rb b/lib/rbs/sorter.rb index 2874f7703..b2035559a 100644 --- a/lib/rbs/sorter.rb +++ b/lib/rbs/sorter.rb @@ -47,9 +47,11 @@ def sort_decl!(decl) singleton_new_methods: [], public_singleton_methods: [], private_singleton_methods: [], + protected_singleton_methods: [], instance_initialize_methods: [], public_instance_methods: [], private_instance_methods: [], + protected_instance_methods: [], } #: partitioned decl.members.each { |m| sort_decl! m } @@ -62,6 +64,8 @@ def sort_decl!(decl) :public when Members::Private :private + when Members::Protected + :protected when Members::MethodDefinition, Members::AttrReader, Members::AttrWriter, Members::AttrAccessor visibility_annotated_members << member.update(visibility: member.visibility || current_visibility) current_visibility @@ -106,16 +110,20 @@ def sort_decl!(decl) partitioned[:singleton_new_methods] << member.update(visibility: nil) elsif member.visibility == :public partitioned[:public_singleton_methods] << member.update(visibility: nil) - else + elsif member.visibility == :private partitioned[:private_singleton_methods] << member.update(visibility: nil) + else + partitioned[:protected_singleton_methods] << member.update(visibility: nil) end else if member.name == :initialize partitioned[:instance_initialize_methods] << member.update(visibility: nil) elsif member.visibility == :public partitioned[:public_instance_methods] << member.update(visibility: nil) - else + elsif member.visibility == :private partitioned[:private_instance_methods] << member.update(visibility: nil) + else + partitioned[:protected_instance_methods] << member.update(visibility: nil) end end when Members::Alias @@ -124,7 +132,7 @@ def sort_decl!(decl) else partitioned[:public_instance_methods] << member end - when Members::Public, Members::Private + when Members::Public, Members::Private, Members::Protected raise else partitioned[:other_decls] << member @@ -145,8 +153,10 @@ def sort_decl!(decl) partitioned[:module_functions].sort_by! {|decl| decl.name.to_s } partitioned[:public_singleton_methods].sort_by! {|decl| decl.is_a?(Members::MethodDefinition) ? decl.name.to_s : decl.new_name.to_s } partitioned[:private_singleton_methods].sort_by! {|decl| decl.name.to_s } + partitioned[:protected_singleton_methods].sort_by! {|decl| decl.name.to_s } partitioned[:public_instance_methods].sort_by! {|decl| decl.is_a?(Members::MethodDefinition) ? decl.name.to_s : decl.new_name.to_s } partitioned[:private_instance_methods].sort_by! {|decl| decl.name.to_s } + partitioned[:protected_instance_methods].sort_by! {|decl| decl.name.to_s } members = [] #: Array[member] members.push(*partitioned[:type_alias_decls]) @@ -172,7 +182,13 @@ def sort_decl!(decl) end members.push(*partitioned[:private_singleton_methods]) - if current_visibility == :private && !partitioned[:public_instance_methods].empty? + if !partitioned[:protected_singleton_methods].empty? + current_visibility = :protected + members.push Members::Protected.new(location: nil) + end + members.push(*partitioned[:protected_singleton_methods]) + + if current_visibility != :public && !partitioned[:public_instance_methods].empty? current_visibility = :public members.push Members::Public.new(location: nil) end @@ -180,12 +196,18 @@ def sort_decl!(decl) members.push(*partitioned[:instance_initialize_methods]) members.push(*partitioned[:public_instance_methods]) - if current_visibility == :public && !partitioned[:private_instance_methods].empty? + if current_visibility != :private && !partitioned[:private_instance_methods].empty? current_visibility = :private members.push Members::Private.new(location: nil) end members.push(*partitioned[:private_instance_methods]) + if current_visibility != :protected && !partitioned[:protected_instance_methods].empty? + current_visibility = :protected + members.push Members::Protected.new(location: nil) + end + members.push(*partitioned[:protected_instance_methods]) + members.push(*partitioned[:other_decls]) decl.members.replace(_ = members) diff --git a/lib/rbs/subtractor.rb b/lib/rbs/subtractor.rb index fe97c9572..5514f6034 100644 --- a/lib/rbs/subtractor.rb +++ b/lib/rbs/subtractor.rb @@ -78,7 +78,7 @@ def call(minuend = @minuend, context: nil) cvar_exist?(owner, member.name) when AST::Members::Include, AST::Members::Extend, AST::Members::Prepend mixin_exist?(owner, member, context: context) - when AST::Members::Public, AST::Members::Private + when AST::Members::Public, AST::Members::Private, AST::Members::Protected # They should not be removed even if the subtrahend has them. false else @@ -158,7 +158,7 @@ def call(minuend = @minuend, context: nil) end private def access_modifier?(decl) - decl.is_a?(AST::Members::Public) || decl.is_a?(AST::Members::Private) + decl.is_a?(AST::Members::Public) || decl.is_a?(AST::Members::Private) || decl.is_a?(AST::Members::Protected) end private def update_decl(decl, members:) diff --git a/lib/rbs/writer.rb b/lib/rbs/writer.rb index 8d80a4c05..6ec5d6c57 100644 --- a/lib/rbs/writer.rb +++ b/lib/rbs/writer.rb @@ -261,6 +261,8 @@ def write_member(member) puts "public" when AST::Members::Private puts "private" + when AST::Members::Protected + puts "protected" when AST::Members::Alias write_comment member.comment write_annotation member.annotations diff --git a/test/rbs/parser_test.rb b/test/rbs/parser_test.rb index ee52200fc..1efa92d91 100644 --- a/test/rbs/parser_test.rb +++ b/test/rbs/parser_test.rb @@ -200,6 +200,7 @@ def test_module_decl_public_private module Foo public private + protected end RBS decls[0].tap do |decl| @@ -207,6 +208,7 @@ module Foo assert_instance_of RBS::AST::Members::Public, decl.members[0] assert_instance_of RBS::AST::Members::Private, decl.members[1] + assert_instance_of RBS::AST::Members::Protected, decl.members[2] end end end diff --git a/test/rbs/signature_parsing_test.rb b/test/rbs/signature_parsing_test.rb index 55855591e..5d81f4c7a 100644 --- a/test/rbs/signature_parsing_test.rb +++ b/test/rbs/signature_parsing_test.rb @@ -529,18 +529,19 @@ def foo: -> void end end - def test_private_public + def test_private_public_protected Parser.parse_signature(<<~SIG).tap do |_, _, decls| class Foo public private + protected end SIG decls[0].yield_self do |decl| assert_instance_of Declarations::Class, decl - assert_equal 2, decl.members.size + assert_equal 3, decl.members.size decl.members[0].yield_self do |m| assert_instance_of Members::Public, m @@ -549,6 +550,10 @@ class Foo decl.members[1].yield_self do |m| assert_instance_of Members::Private, m end + + decl.members[2].yield_self do |m| + assert_instance_of Members::Protected, m + end end end end @@ -559,13 +564,14 @@ class Foo public def foo: () -> void private def bar: () -> void def baz: () -> void + protected def quux: () -> void end SIG decls[0].tap do |decl| assert_instance_of Declarations::Class, decl - assert_equal 3, decl.members.size + assert_equal 4, decl.members.size decl.members[0].tap do |m| assert_instance_of Members::MethodDefinition, m @@ -584,6 +590,12 @@ def baz: () -> void assert_equal :baz, m.name assert_nil m.visibility end + + decl.members[3].tap do |m| + assert_instance_of Members::MethodDefinition, m + assert_equal :quux, m.name + assert_equal :protected, m.visibility + end end end end @@ -604,13 +616,14 @@ class Foo public attr_reader foo: String private attr_reader bar: String attr_reader baz: String + protected attr_reader quux: String end SIG decls[0].tap do |decl| assert_instance_of Declarations::Class, decl - assert_equal 3, decl.members.size + assert_equal 4, decl.members.size decl.members[0].tap do |m| assert_instance_of Members::AttrReader, m @@ -629,6 +642,12 @@ class Foo assert_equal :baz, m.name assert_nil m.visibility end + + decl.members[3].tap do |m| + assert_instance_of Members::AttrReader, m + assert_equal :quux, m.name + assert_equal :protected, m.visibility + end end end end @@ -650,6 +669,8 @@ class Foo private + protected + public # comment can follow end SIG @@ -704,6 +725,7 @@ def singleton: -> String def type: -> String def module: -> String def private: -> String + def protected: -> String def public: -> untyped def interface: -> untyped def super: -> untyped @@ -747,6 +769,7 @@ def _foo!: -> untyped :type, :module, :private, + :protected, :public, :interface, :super,