From 33403701819d71c01fb061aeb03aea672ec10f82 Mon Sep 17 00:00:00 2001 From: yui-knk <spiketeika@gmail.com> Date: Sun, 10 Dec 2023 18:36:02 +0900 Subject: [PATCH] Use brace instead of paren for `%parser-state` --- lib/lrama/parser.rb | 156 +++++++++++------------ parser.y | 2 +- spec/fixtures/integration/parser_state.y | 6 +- 3 files changed, 82 insertions(+), 82 deletions(-) diff --git a/lib/lrama/parser.rb b/lib/lrama/parser.rb index 5d8e2148..5ab817c5 100644 --- a/lib/lrama/parser.rb +++ b/lib/lrama/parser.rb @@ -757,27 +757,27 @@ def carrets(text, first_column, last_column) ##### State transition tables begin ### racc_action_table = [ - 87, 45, 88, 152, 216, 69, 142, 6, 45, 7, - 152, 148, 69, 3, 45, 151, 204, 154, 69, 45, - 143, 204, 8, 69, 154, 149, 174, 175, 176, 150, - 205, 174, 175, 176, 85, 205, 41, 207, 35, 155, - 156, 157, 158, 42, 48, 89, 155, 156, 157, 158, - 41, 208, 206, 48, 229, 82, 48, 206, 22, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 208, 45, - 51, 44, 22, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 9, 45, 52, 44, 13, 14, 15, 16, - 17, 18, 53, 54, 19, 20, 55, 56, 21, 22, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 45, 45, 44, 44, 45, 60, 44, 57, 69, 65, - 45, 45, 44, 44, 78, 72, 72, 45, 45, 44, - 44, 79, 72, 72, 45, 45, 44, 44, 69, 187, - 45, 45, 44, 44, 69, 187, 45, 45, 44, 44, - 69, 187, 45, 45, 44, 44, 69, 187, 45, 45, - 44, 44, 69, 187, 45, 45, 44, 44, 69, 187, - 45, 45, 44, 44, 69, 69, 45, 45, 44, 44, - 69, 69, 45, 45, 44, 44, 69, 69, 45, 45, - 44, 44, 69, 69, 45, 45, 44, 44, 69, 69, - 45, 45, 44, 44, 83, 85, 90, 90, 90, 92, + 87, 45, 88, 152, 142, 69, 3, 8, 45, 151, + 152, 45, 69, 44, 45, 69, 204, 154, 69, 45, + 35, 204, 143, 69, 154, 150, 45, 6, 44, 7, + 205, 60, 45, 42, 44, 205, 69, 65, 41, 155, + 156, 157, 158, 48, 48, 89, 155, 156, 157, 158, + 41, 45, 206, 44, 48, 82, 72, 206, 22, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 51, 52, + 22, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 9, 45, 53, 44, 13, 14, 15, 16, 17, 18, + 54, 55, 19, 20, 21, 22, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 216, 45, 45, 44, + 44, 56, 72, 72, 57, 78, 174, 175, 176, 45, + 45, 44, 44, 45, 72, 44, 79, 69, 187, 45, + 45, 44, 44, 69, 187, 45, 45, 44, 44, 69, + 187, 45, 45, 44, 44, 69, 187, 45, 45, 44, + 44, 69, 187, 45, 45, 44, 44, 69, 187, 45, + 45, 44, 44, 69, 69, 45, 45, 44, 44, 69, + 69, 45, 45, 44, 44, 69, 69, 45, 45, 44, + 44, 69, 69, 45, 45, 44, 44, 69, 174, 175, + 176, 85, 45, 45, 44, 44, 45, 148, 44, 149, + 207, 229, 208, 208, 83, 85, 90, 90, 90, 92, 94, 99, 103, 104, 107, 107, 107, 107, 110, 113, 114, 116, 118, 120, 121, 122, 123, 124, 127, 131, 132, 133, 136, 137, 138, 140, 160, 162, 163, 164, @@ -787,27 +787,27 @@ def carrets(text, first_column, last_column) 227, 228, 231, 85 ] racc_action_check = [ - 43, 135, 43, 135, 204, 135, 119, 2, 170, 2, - 170, 130, 170, 1, 191, 134, 191, 135, 191, 213, - 119, 213, 3, 213, 170, 130, 204, 204, 204, 134, - 191, 153, 153, 153, 153, 213, 9, 193, 7, 135, - 135, 135, 135, 13, 15, 43, 170, 170, 170, 170, - 36, 193, 191, 16, 224, 36, 17, 213, 9, 9, - 9, 9, 9, 9, 9, 9, 9, 9, 224, 14, - 18, 14, 36, 36, 36, 36, 36, 36, 36, 36, - 36, 36, 4, 59, 19, 59, 4, 4, 4, 4, - 4, 4, 20, 22, 4, 4, 24, 25, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 27, 60, 27, 60, 28, 27, 28, 26, 28, 28, - 29, 30, 29, 30, 33, 29, 30, 31, 32, 31, - 32, 34, 31, 32, 165, 71, 165, 71, 165, 165, - 166, 72, 166, 72, 166, 166, 167, 99, 167, 99, - 167, 167, 184, 101, 184, 101, 184, 184, 188, 107, - 188, 107, 188, 188, 189, 109, 189, 109, 189, 189, - 64, 65, 64, 65, 64, 65, 104, 106, 104, 106, - 104, 106, 128, 155, 128, 155, 128, 155, 171, 206, - 171, 206, 171, 206, 208, 216, 208, 216, 208, 216, - 125, 129, 125, 129, 39, 40, 47, 49, 50, 51, + 43, 135, 43, 135, 119, 135, 1, 3, 170, 134, + 170, 64, 170, 64, 191, 64, 191, 135, 191, 213, + 7, 213, 119, 213, 170, 134, 27, 2, 27, 2, + 191, 27, 28, 13, 28, 213, 28, 28, 9, 135, + 135, 135, 135, 15, 16, 43, 170, 170, 170, 170, + 36, 29, 191, 29, 17, 36, 29, 213, 9, 9, + 9, 9, 9, 9, 9, 9, 9, 9, 18, 19, + 36, 36, 36, 36, 36, 36, 36, 36, 36, 36, + 4, 14, 20, 14, 4, 4, 4, 4, 4, 4, + 22, 24, 4, 4, 4, 4, 4, 4, 4, 4, + 4, 4, 4, 4, 4, 4, 204, 30, 31, 30, + 31, 25, 30, 31, 26, 33, 204, 204, 204, 32, + 59, 32, 59, 165, 32, 165, 34, 165, 165, 166, + 60, 166, 60, 166, 166, 167, 71, 167, 71, 167, + 167, 184, 72, 184, 72, 184, 184, 188, 99, 188, + 99, 188, 188, 189, 101, 189, 101, 189, 189, 65, + 104, 65, 104, 65, 104, 106, 128, 106, 128, 106, + 128, 155, 171, 155, 171, 155, 171, 206, 208, 206, + 208, 206, 208, 216, 107, 216, 107, 216, 153, 153, + 153, 153, 109, 125, 109, 125, 129, 130, 129, 130, + 193, 224, 193, 224, 39, 40, 47, 49, 50, 51, 53, 58, 62, 63, 70, 75, 76, 77, 78, 84, 85, 91, 93, 94, 95, 96, 97, 98, 102, 110, 111, 112, 113, 114, 115, 117, 139, 141, 143, 144, @@ -817,29 +817,29 @@ def carrets(text, first_column, last_column) 222, 223, 230, 231 ] racc_action_pointer = [ - nil, 13, -3, 22, 73, nil, nil, 31, nil, 32, - nil, nil, nil, 37, 66, 25, 34, 37, 65, 65, - 87, nil, 74, nil, 77, 78, 98, 107, 111, 117, - 118, 124, 125, 119, 129, nil, 46, nil, nil, 179, + nil, 6, 17, 7, 71, nil, nil, 13, nil, 34, + nil, nil, nil, 27, 78, 24, 25, 35, 63, 50, + 77, nil, 71, nil, 72, 92, 95, 23, 29, 48, + 104, 105, 116, 110, 124, nil, 46, nil, nil, 181, 157, nil, nil, -5, nil, nil, nil, 187, nil, 188, - 189, 190, nil, 187, nil, nil, nil, nil, 203, 80, - 108, nil, 206, 205, 167, 168, nil, nil, nil, nil, - 206, 132, 138, nil, nil, 207, 208, 209, 195, nil, + 189, 190, nil, 191, nil, nil, nil, nil, 203, 117, + 127, nil, 206, 205, 8, 156, nil, nil, nil, nil, + 206, 133, 139, nil, nil, 207, 208, 209, 183, nil, nil, nil, nil, nil, 182, 215, nil, nil, nil, nil, - nil, 219, nil, 220, 218, 222, 223, 224, 225, 144, - nil, 150, 221, nil, 173, nil, 174, 156, nil, 162, - 224, 219, 229, 192, 184, 232, nil, 233, nil, -18, - nil, nil, nil, nil, nil, 197, nil, nil, 179, 198, - -13, nil, nil, nil, -10, -2, nil, nil, nil, 216, + nil, 219, nil, 220, 218, 222, 223, 224, 225, 145, + nil, 151, 221, nil, 157, nil, 162, 181, nil, 189, + 224, 219, 229, 192, 184, 232, nil, 233, nil, -16, + nil, nil, nil, nil, nil, 190, nil, nil, 163, 193, + 161, nil, nil, nil, -14, -2, nil, nil, nil, 216, nil, 217, nil, 233, 219, 220, 221, 222, 206, 239, - 205, nil, 223, -14, nil, 180, 224, 225, 226, 230, - nil, 231, nil, nil, nil, 131, 137, 143, 212, nil, - 5, 185, nil, 245, nil, nil, nil, 252, nil, 250, - 251, 252, nil, nil, 149, nil, nil, nil, 155, 161, - 219, 11, nil, 13, nil, nil, nil, nil, 221, 236, - 223, nil, 222, 215, -19, nil, 186, 256, 191, 245, - 261, nil, 262, 16, nil, nil, 192, 266, nil, nil, - nil, 221, 246, 247, 30, nil, nil, nil, nil, nil, + 205, nil, 211, 143, nil, 168, 212, 213, 214, 230, + nil, 231, nil, nil, nil, 120, 126, 132, 212, nil, + 5, 169, nil, 245, nil, nil, nil, 252, nil, 250, + 251, 252, nil, nil, 138, nil, nil, nil, 144, 150, + 219, 11, nil, 164, nil, nil, nil, nil, 221, 224, + 223, nil, 222, 215, 71, nil, 174, 256, 175, 245, + 261, nil, 262, 16, nil, nil, 180, 266, nil, nil, + nil, 221, 234, 235, 165, nil, nil, nil, nil, nil, 252, 225, nil ] racc_action_default = [ @@ -1094,20 +1094,20 @@ def carrets(text, first_column, last_column) "}" => 20, "%initial-action" => 21, "%parser-state" => 22, - "(" => 23, - ")" => 24, - ";" => 25, - "%union" => 26, - "%destructor" => 27, - "%printer" => 28, - "%error-token" => 29, - "%token" => 30, - "%type" => 31, - "%left" => 32, - "%right" => 33, - "%precedence" => 34, - "%nonassoc" => 35, - "%rule" => 36, + ";" => 23, + "%union" => 24, + "%destructor" => 25, + "%printer" => 26, + "%error-token" => 27, + "%token" => 28, + "%type" => 29, + "%left" => 30, + "%right" => 31, + "%precedence" => 32, + "%nonassoc" => 33, + "%rule" => 34, + "(" => 35, + ")" => 36, ":" => 37, "," => 38, "|" => 39, @@ -1168,8 +1168,6 @@ def carrets(text, first_column, last_column) "\"}\"", "\"%initial-action\"", "\"%parser-state\"", - "\"(\"", - "\")\"", "\";\"", "\"%union\"", "\"%destructor\"", @@ -1182,6 +1180,8 @@ def carrets(text, first_column, last_column) "\"%precedence\"", "\"%nonassoc\"", "\"%rule\"", + "\"(\"", + "\")\"", "\":\"", "\",\"", "\"|\"", diff --git a/parser.y b/parser.y index 6defe797..f171d5f9 100644 --- a/parser.y +++ b/parser.y @@ -69,7 +69,7 @@ rule { @grammar.initial_action = Grammar::Code::InitialActionCode.new(type: :initial_action, token_code: val[3]) } - | "%parser-state" IDENTIFIER "(" identifier_list ")" + | "%parser-state" IDENTIFIER "{" identifier_list "}" { @grammar.add_parser_state(val[1], val[3]) } diff --git a/spec/fixtures/integration/parser_state.y b/spec/fixtures/integration/parser_state.y index d13c481f..35d36939 100644 --- a/spec/fixtures/integration/parser_state.y +++ b/spec/fixtures/integration/parser_state.y @@ -17,9 +17,9 @@ static int yyerror(YYLTYPE *loc, const char *str); %expect 0 -%parser-state in_rescue (before_rescue, after_rescue, after_else, after_ensure) -%parser-state in_def (in_def, not_in_def) -%parser-state in_class (in_class, not_in_class) +%parser-state in_rescue { before_rescue, after_rescue, after_else, after_ensure } +%parser-state in_def { in_def, not_in_def } +%parser-state in_class { in_class, not_in_class } %token <i> keyword_begin keyword_end keyword_rescue keyword_else keyword_ensure keyword_class keyword_def %token <i> NUM