From f00e4ad90087ec9a5c3378db398b248025855f5f Mon Sep 17 00:00:00 2001 From: ydah Date: Tue, 1 Oct 2024 23:23:58 +0900 Subject: [PATCH] Use `string_as_id?` --- lib/lrama/parser.rb | 452 ++++++++++++++++++++++---------------------- parser.y | 3 +- 2 files changed, 229 insertions(+), 226 deletions(-) diff --git a/lib/lrama/parser.rb b/lib/lrama/parser.rb index 6a35dba2..dbbd2a41 100644 --- a/lib/lrama/parser.rb +++ b/lib/lrama/parser.rb @@ -654,7 +654,7 @@ def token_to_str(t) module Lrama class Parser < Racc::Parser -module_eval(<<'...end parser.y/module_eval...', 'parser.y', 417) +module_eval(<<'...end parser.y/module_eval...', 'parser.y', 416) include Lrama::Report::Duration @@ -728,12 +728,12 @@ def raise_parse_error(error_message, location) ##### State transition tables begin ### racc_action_table = [ - 94, 48, 95, 166, 48, 77, 172, 48, 77, 166, - 48, 77, 172, 48, 77, 47, 6, 85, 69, 48, + 94, 48, 95, 167, 48, 77, 173, 48, 77, 167, + 48, 77, 173, 48, 77, 47, 6, 85, 69, 48, 48, 47, 47, 77, 74, 81, 48, 48, 47, 47, 40, 81, 81, 48, 41, 47, 92, 48, 81, 47, - 44, 77, 103, 168, 169, 45, 175, 169, 96, 168, - 169, 52, 175, 169, 86, 20, 24, 25, 26, 27, + 44, 77, 103, 169, 170, 45, 176, 170, 96, 169, + 170, 52, 176, 170, 86, 20, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 92, 48, 4, 47, 5, 77, 103, 48, 48, 47, 47, 77, 103, 116, 48, 4, 47, 5, 77, @@ -745,26 +745,26 @@ def raise_parse_error(error_message, location) 19, 43, 20, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 48, 48, 47, 47, 77, 103, 48, 48, 47, 47, 77, 77, - 48, 48, 47, 47, 77, 77, 48, 48, 196, 196, - 77, 77, 48, 48, 47, 196, 77, 77, 148, 170, - 52, 149, 149, 180, 181, 182, 131, 180, 181, 182, - 131, 203, 208, 215, 204, 204, 204, 48, 48, 47, - 47, 48, 48, 47, 47, 48, 48, 47, 47, 180, - 181, 182, 119, 120, 55, 52, 52, 52, 52, 52, + 48, 48, 47, 47, 77, 77, 48, 48, 197, 197, + 77, 77, 48, 48, 47, 197, 77, 77, 149, 171, + 52, 150, 150, 181, 182, 183, 131, 181, 182, 183, + 131, 204, 209, 216, 205, 205, 205, 48, 48, 47, + 47, 48, 48, 47, 47, 48, 48, 47, 47, 181, + 182, 183, 119, 120, 55, 52, 52, 52, 52, 52, 61, 62, 63, 64, 65, 87, 52, 52, 106, 109, - 111, 118, 125, 126, 128, 131, 132, 77, 140, 141, - 142, 143, 145, 146, 153, 140, 155, 153, 159, 160, - 161, 163, 164, 171, 176, 153, 183, 131, 187, 153, - 189, 131, 153, 198, 153, 131, 161, 164, 205, 164, - 161, 161, 213, 131, 161 ] + 111, 118, 125, 126, 128, 131, 132, 77, 141, 142, + 143, 144, 146, 147, 154, 141, 156, 154, 160, 161, + 162, 164, 165, 172, 177, 154, 184, 131, 188, 154, + 190, 131, 154, 199, 154, 131, 162, 165, 206, 165, + 162, 162, 214, 131, 162 ] racc_action_check = [ - 46, 151, 46, 151, 157, 151, 157, 177, 157, 177, - 188, 177, 188, 32, 188, 32, 1, 38, 32, 33, + 46, 152, 46, 152, 158, 152, 158, 178, 158, 178, + 189, 178, 189, 32, 189, 32, 1, 38, 32, 33, 34, 33, 34, 33, 33, 34, 35, 36, 35, 36, 5, 35, 36, 37, 6, 37, 44, 58, 37, 58, - 9, 58, 58, 151, 151, 11, 157, 157, 46, 177, - 177, 13, 188, 188, 38, 44, 44, 44, 44, 44, + 9, 58, 58, 152, 152, 11, 158, 158, 46, 178, + 178, 13, 189, 189, 38, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 44, 88, 59, 0, 59, 0, 59, 59, 60, 79, 60, 79, 60, 60, 79, 72, 2, 72, 2, 72, @@ -776,18 +776,18 @@ def raise_parse_error(error_message, location) 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 100, 12, 100, 12, 100, 100, 74, 111, 74, 111, 74, 111, - 168, 175, 168, 175, 168, 175, 183, 189, 183, 189, - 183, 189, 204, 205, 204, 205, 204, 205, 139, 154, - 15, 139, 154, 165, 165, 165, 165, 173, 173, 173, - 173, 195, 200, 212, 195, 200, 212, 67, 69, 67, - 69, 81, 106, 81, 106, 114, 116, 114, 116, 197, - 197, 197, 86, 86, 16, 17, 20, 24, 25, 26, + 169, 176, 169, 176, 169, 176, 184, 190, 184, 190, + 184, 190, 205, 206, 205, 206, 205, 206, 140, 155, + 15, 140, 155, 166, 166, 166, 166, 174, 174, 174, + 174, 196, 201, 213, 196, 201, 213, 67, 69, 67, + 69, 81, 106, 81, 106, 114, 116, 114, 116, 198, + 198, 198, 86, 86, 16, 17, 20, 24, 25, 26, 27, 28, 29, 30, 31, 39, 50, 55, 66, 70, 71, 85, 89, 90, 91, 92, 98, 110, 118, 119, - 120, 121, 130, 131, 141, 142, 144, 145, 146, 147, - 148, 149, 150, 156, 162, 164, 166, 167, 170, 171, - 172, 174, 176, 186, 187, 191, 192, 194, 196, 199, - 201, 203, 207, 208, 214 ] + 120, 121, 130, 131, 142, 143, 145, 146, 147, 148, + 149, 150, 151, 157, 163, 165, 167, 168, 171, 172, + 173, 175, 177, 187, 188, 192, 193, 195, 197, 200, + 202, 204, 208, 209, 215 ] racc_action_pointer = [ 63, 16, 76, 93, nil, 23, 34, nil, 119, 31, @@ -803,89 +803,89 @@ def raise_parse_error(error_message, location) 155, nil, nil, nil, nil, nil, 209, nil, nil, nil, 240, 162, nil, nil, 212, nil, 213, nil, 243, 208, 211, 240, nil, nil, nil, nil, nil, nil, nil, nil, - 211, 248, nil, nil, nil, nil, nil, nil, nil, 148, - nil, 200, 250, nil, 254, 203, 206, 212, 252, 256, - 218, -2, nil, nil, 149, nil, 219, 1, nil, nil, - nil, nil, 223, nil, 211, 145, 227, 216, 167, nil, - 227, 215, 231, 149, 220, 168, 218, 4, nil, nil, - nil, nil, nil, 173, nil, nil, 271, 220, 7, 174, - nil, 224, 268, nil, 233, 161, 239, 171, nil, 235, - 162, 272, nil, 273, 179, 180, nil, 235, 232, nil, - nil, nil, 163, nil, 276, nil, nil ] + 211, 248, nil, nil, nil, nil, nil, nil, nil, nil, + 148, nil, 200, 250, nil, 254, 203, 206, 212, 252, + 256, 218, -2, nil, nil, 149, nil, 219, 1, nil, + nil, nil, nil, 223, nil, 211, 145, 227, 216, 167, + nil, 227, 215, 231, 149, 220, 168, 218, 4, nil, + nil, nil, nil, nil, 173, nil, nil, 271, 220, 7, + 174, nil, 224, 268, nil, 233, 161, 239, 171, nil, + 235, 162, 272, nil, 273, 179, 180, nil, 235, 232, + nil, nil, nil, 163, nil, 276, nil, nil ] racc_action_default = [ - -1, -127, -1, -3, -10, -127, -127, -2, -3, -127, - -16, -127, -127, -127, -127, -127, -127, -127, -24, -25, - -127, -30, -31, -32, -127, -127, -127, -127, -127, -127, - -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, - -13, 217, -4, -26, -127, -17, -118, -89, -90, -117, - -14, -19, -81, -20, -21, -127, -23, -29, -127, -127, - -127, -36, -37, -38, -39, -40, -41, -47, -49, -127, - -52, -42, -74, -76, -127, -79, -80, -126, -43, -84, - -86, -127, -44, -45, -46, -127, -127, -11, -5, -7, - -91, -127, -64, -18, -119, -120, -121, -15, -127, -22, - -27, -33, -122, -123, -34, -35, -127, -48, -50, -53, - -72, -127, -75, -77, -84, -85, -127, -87, -127, -127, - -127, -127, -6, -8, -9, -115, -92, -93, -94, -65, - -127, -127, -82, -28, -51, -54, -73, -78, -88, -127, - -60, -124, -127, -12, -127, -124, -127, -127, -55, -127, - -58, -62, -66, -125, -127, -116, -95, -96, -98, -114, - -83, -56, -127, -61, -124, -64, -89, -64, -127, -111, - -127, -124, -89, -64, -64, -127, -124, -63, -67, -68, - -104, -105, -106, -127, -70, -71, -127, -124, -97, -127, - -99, -64, -55, -103, -57, -127, -89, -107, -112, -59, - -127, -55, -102, -55, -127, -127, -109, -127, -64, -100, - -69, -108, -127, -113, -55, -110, -101 ] + -1, -128, -1, -3, -10, -128, -128, -2, -3, -128, + -16, -128, -128, -128, -128, -128, -128, -128, -24, -25, + -128, -30, -31, -32, -128, -128, -128, -128, -128, -128, + -128, -128, -128, -128, -128, -128, -128, -128, -128, -128, + -13, 218, -4, -26, -128, -17, -119, -90, -91, -118, + -14, -19, -82, -20, -21, -128, -23, -29, -128, -128, + -128, -36, -37, -38, -39, -40, -41, -47, -49, -128, + -52, -42, -75, -77, -128, -80, -81, -127, -43, -85, + -87, -128, -44, -45, -46, -128, -128, -11, -5, -7, + -92, -128, -64, -18, -120, -121, -122, -15, -128, -22, + -27, -33, -123, -124, -34, -35, -128, -48, -50, -53, + -72, -128, -76, -78, -85, -86, -128, -88, -128, -128, + -128, -128, -6, -8, -9, -116, -93, -94, -95, -65, + -128, -128, -83, -28, -51, -54, -73, -74, -79, -89, + -128, -60, -125, -128, -12, -128, -125, -128, -128, -55, + -128, -58, -62, -66, -126, -128, -117, -96, -97, -99, + -115, -84, -56, -128, -61, -125, -64, -90, -64, -128, + -112, -128, -125, -90, -64, -64, -128, -125, -63, -67, + -68, -105, -106, -107, -128, -70, -71, -128, -125, -98, + -128, -100, -64, -55, -104, -57, -128, -90, -108, -113, + -59, -128, -55, -103, -55, -128, -128, -110, -128, -64, + -101, -69, -109, -128, -114, -55, -111, -102 ] racc_goto_table = [ - 102, 102, 102, 49, 130, 73, 68, 89, 162, 91, - 150, 139, 101, 104, 105, 1, 9, 174, 51, 53, - 54, 42, 115, 70, 117, 79, 79, 79, 79, 56, - 123, 3, 57, 7, 124, 154, 58, 59, 60, 179, - 158, 107, 102, 108, 112, 194, 113, 191, 174, 157, - 39, 122, 202, 91, 133, 97, 199, 115, 70, 138, - 70, 209, 195, 210, 121, 46, 158, 99, 200, 93, - 114, 206, 114, 66, 216, 188, 71, 178, 135, 184, - 134, 110, 177, 137, 212, 190, 192, 78, 82, 83, - 84, 136, 98, 165, 147, 127, 156, 70, 186, 173, - 207, 144, nil, 201, nil, 114, nil, 114, nil, nil, - 185, nil, nil, nil, nil, nil, nil, 193, nil, 165, - 214, nil, nil, nil, nil, 197, nil, nil, nil, nil, - 173, 197, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, 211, 197 ] + 102, 102, 102, 49, 130, 73, 151, 89, 68, 163, + 91, 196, 1, 101, 104, 105, 175, 201, 123, 51, + 53, 54, 115, 70, 117, 79, 79, 79, 79, 56, + 124, 180, 57, 213, 39, 159, 58, 59, 60, 192, + 158, 195, 102, 107, 112, 108, 113, 175, 140, 121, + 46, 122, 200, 203, 91, 133, 97, 115, 70, 139, + 70, 159, 210, 207, 211, 93, 189, 99, 66, 9, + 114, 71, 114, 155, 42, 217, 135, 3, 179, 7, + 185, 110, 134, 138, 178, 136, 191, 193, 78, 82, + 83, 84, 137, 98, 166, 148, 127, 70, 157, 187, + 174, 208, 145, nil, 202, 114, nil, 114, nil, nil, + nil, 186, nil, nil, nil, nil, nil, nil, 194, nil, + 166, 215, nil, nil, nil, nil, 198, nil, nil, nil, + nil, 174, 198, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, 212, 198 ] racc_goto_check = [ - 35, 35, 35, 27, 40, 42, 26, 8, 32, 12, - 31, 30, 21, 21, 21, 1, 7, 39, 16, 16, - 16, 7, 45, 27, 45, 27, 27, 27, 27, 15, - 5, 6, 15, 6, 9, 30, 15, 15, 15, 37, - 34, 26, 35, 26, 42, 31, 42, 37, 39, 49, - 10, 8, 32, 12, 21, 16, 31, 45, 27, 45, - 27, 32, 38, 32, 11, 13, 34, 15, 38, 14, - 27, 37, 27, 22, 32, 49, 23, 40, 28, 40, - 26, 29, 33, 42, 38, 40, 40, 24, 24, 24, - 24, 41, 43, 35, 44, 47, 48, 27, 50, 35, - 51, 52, nil, 40, nil, 27, nil, 27, nil, nil, - 35, nil, nil, nil, nil, nil, nil, 35, nil, 35, - 40, nil, nil, nil, nil, 35, nil, nil, nil, nil, - 35, 35, nil, nil, nil, nil, nil, nil, nil, nil, - nil, nil, nil, nil, nil, nil, 35, 35 ] + 35, 35, 35, 27, 40, 43, 31, 8, 26, 32, + 12, 38, 1, 21, 21, 21, 39, 38, 5, 16, + 16, 16, 46, 27, 46, 27, 27, 27, 27, 15, + 9, 37, 15, 38, 10, 34, 15, 15, 15, 37, + 50, 31, 35, 26, 43, 26, 43, 39, 30, 11, + 13, 8, 31, 32, 12, 21, 16, 46, 27, 46, + 27, 34, 32, 37, 32, 14, 50, 15, 22, 7, + 27, 23, 27, 30, 7, 32, 28, 6, 40, 6, + 40, 29, 26, 43, 33, 41, 40, 40, 24, 24, + 24, 24, 42, 44, 35, 45, 48, 27, 49, 51, + 35, 52, 53, nil, 40, 27, nil, 27, nil, nil, + nil, 35, nil, nil, nil, nil, nil, nil, 35, nil, + 35, 40, nil, nil, nil, nil, 35, nil, nil, nil, + nil, 35, 35, nil, nil, nil, nil, nil, nil, nil, + nil, nil, nil, nil, nil, nil, nil, 35, 35 ] racc_goto_pointer = [ - nil, 15, nil, nil, nil, -59, 31, 13, -37, -55, - 46, -23, -35, 53, 23, 12, 5, nil, nil, nil, - nil, -46, 41, 43, 53, nil, -26, -9, -32, 11, - -107, -131, -140, -82, -105, -58, nil, -126, -121, -140, - -88, -19, -28, 40, -38, -57, nil, 5, -49, -96, - -71, -98, -24 ] + nil, 12, nil, nil, nil, -71, 77, 66, -37, -59, + 30, -38, -34, 38, 19, 12, 6, nil, nil, nil, + nil, -45, 36, 38, 54, nil, -24, -9, -34, 11, + -70, -136, -140, -81, -111, -58, nil, -135, -173, -142, + -88, -25, -18, -28, 41, -37, -57, nil, 6, -48, + -106, -71, -98, -23 ] racc_goto_default = [ nil, nil, 2, 8, 88, nil, nil, nil, nil, nil, nil, nil, 10, nil, nil, 50, nil, 21, 22, 23, 100, nil, nil, nil, nil, 67, nil, 75, nil, nil, - nil, nil, nil, 151, 152, 72, 129, nil, nil, 167, - nil, 76, nil, nil, nil, 80, 90, nil, nil, nil, - nil, nil, nil ] + nil, nil, nil, 152, 153, 72, 129, nil, nil, 168, + nil, 76, nil, nil, nil, nil, 80, 90, nil, nil, + nil, nil, nil, nil ] racc_reduce_table = [ 0, 0, :racc_error, @@ -960,51 +960,52 @@ def raise_parse_error(error_message, location) 6, 88, :_reduce_69, 3, 88, :_reduce_70, 3, 88, :_reduce_71, - 0, 83, :_reduce_none, - 1, 83, :_reduce_73, - 1, 97, :_reduce_74, - 2, 97, :_reduce_75, - 1, 78, :_reduce_76, - 2, 78, :_reduce_77, - 3, 78, :_reduce_78, + 0, 97, :_reduce_none, + 1, 97, :_reduce_none, + 1, 83, :_reduce_74, + 1, 98, :_reduce_75, + 2, 98, :_reduce_76, + 1, 78, :_reduce_77, + 2, 78, :_reduce_78, + 3, 78, :_reduce_79, 1, 90, :_reduce_none, 1, 90, :_reduce_none, - 0, 98, :_reduce_81, 0, 99, :_reduce_82, - 5, 70, :_reduce_83, - 1, 100, :_reduce_84, - 2, 100, :_reduce_85, - 1, 79, :_reduce_86, - 2, 79, :_reduce_87, - 3, 79, :_reduce_88, - 1, 82, :_reduce_89, + 0, 100, :_reduce_83, + 5, 70, :_reduce_84, + 1, 101, :_reduce_85, + 2, 101, :_reduce_86, + 1, 79, :_reduce_87, + 2, 79, :_reduce_88, + 3, 79, :_reduce_89, 1, 82, :_reduce_90, - 0, 102, :_reduce_none, - 1, 102, :_reduce_none, + 1, 82, :_reduce_91, + 0, 103, :_reduce_none, + 1, 103, :_reduce_none, 2, 59, :_reduce_none, 2, 59, :_reduce_none, - 4, 101, :_reduce_95, - 1, 103, :_reduce_96, - 3, 103, :_reduce_97, - 1, 104, :_reduce_98, - 3, 104, :_reduce_99, - 5, 104, :_reduce_100, - 7, 104, :_reduce_101, - 4, 104, :_reduce_102, - 3, 104, :_reduce_103, - 1, 92, :_reduce_104, + 4, 102, :_reduce_96, + 1, 104, :_reduce_97, + 3, 104, :_reduce_98, + 1, 105, :_reduce_99, + 3, 105, :_reduce_100, + 5, 105, :_reduce_101, + 7, 105, :_reduce_102, + 4, 105, :_reduce_103, + 3, 105, :_reduce_104, 1, 92, :_reduce_105, 1, 92, :_reduce_106, - 1, 93, :_reduce_107, - 3, 93, :_reduce_108, - 2, 93, :_reduce_109, - 4, 93, :_reduce_110, - 0, 105, :_reduce_111, + 1, 92, :_reduce_107, + 1, 93, :_reduce_108, + 3, 93, :_reduce_109, + 2, 93, :_reduce_110, + 4, 93, :_reduce_111, 0, 106, :_reduce_112, - 5, 94, :_reduce_113, - 3, 91, :_reduce_114, - 0, 107, :_reduce_115, - 3, 60, :_reduce_116, + 0, 107, :_reduce_113, + 5, 94, :_reduce_114, + 3, 91, :_reduce_115, + 0, 108, :_reduce_116, + 3, 60, :_reduce_117, 1, 68, :_reduce_none, 0, 69, :_reduce_none, 1, 69, :_reduce_none, @@ -1014,11 +1015,11 @@ def raise_parse_error(error_message, location) 1, 75, :_reduce_none, 0, 89, :_reduce_none, 1, 89, :_reduce_none, - 1, 96, :_reduce_126 ] + 1, 96, :_reduce_127 ] -racc_reduce_n = 127 +racc_reduce_n = 128 -racc_shift_n = 217 +racc_shift_n = 218 racc_token_table = { false => 0, @@ -1196,6 +1197,7 @@ def raise_parse_error(error_message, location) "midrule_action", "\"-option@named_ref\"", "string_as_id", + "\"-option@string_as_id\"", "\"-many1@symbol\"", "@3", "@4", @@ -1735,135 +1737,137 @@ def _reduce_71(val, _values, result) # reduce 72 omitted -module_eval(<<'.,.,', 'parser.y', 253) - def _reduce_73(val, _values, result) - result = val[0].s_value +# reduce 73 omitted + +module_eval(<<'.,.,', 'parser.y', 252) + def _reduce_74(val, _values, result) + result = val[0].s_value if val[0] result end .,., -module_eval(<<'.,.,', 'parser.y', 260) - def _reduce_74(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 259) + def _reduce_75(val, _values, result) result = val[1] ? val[1].unshift(val[0]) : val result end .,., -module_eval(<<'.,.,', 'parser.y', 260) - def _reduce_75(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 259) + def _reduce_76(val, _values, result) result = val[1] ? val[1].unshift(val[0]) : val result end .,., -module_eval(<<'.,.,', 'parser.y', 255) - def _reduce_76(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 254) + def _reduce_77(val, _values, result) result = [{tag: nil, tokens: val[0]}] result end .,., -module_eval(<<'.,.,', 'parser.y', 256) - def _reduce_77(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 255) + def _reduce_78(val, _values, result) result = [{tag: val[0], tokens: val[1]}] result end .,., -module_eval(<<'.,.,', 'parser.y', 257) - def _reduce_78(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 256) + def _reduce_79(val, _values, result) result = val[0].append({tag: val[1], tokens: val[2]}) result end .,., -# reduce 79 omitted - # reduce 80 omitted -module_eval(<<'.,.,', 'parser.y', 263) - def _reduce_81(val, _values, result) +# reduce 81 omitted + +module_eval(<<'.,.,', 'parser.y', 262) + def _reduce_82(val, _values, result) begin_c_declaration("}") result end .,., -module_eval(<<'.,.,', 'parser.y', 267) - def _reduce_82(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 266) + def _reduce_83(val, _values, result) end_c_declaration result end .,., -module_eval(<<'.,.,', 'parser.y', 271) - def _reduce_83(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 270) + def _reduce_84(val, _values, result) result = val[2] result end .,., -module_eval(<<'.,.,', 'parser.y', 279) - def _reduce_84(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 278) + def _reduce_85(val, _values, result) result = val[1] ? val[1].unshift(val[0]) : val result end .,., -module_eval(<<'.,.,', 'parser.y', 279) - def _reduce_85(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 278) + def _reduce_86(val, _values, result) result = val[1] ? val[1].unshift(val[0]) : val result end .,., -module_eval(<<'.,.,', 'parser.y', 274) - def _reduce_86(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 273) + def _reduce_87(val, _values, result) result = [{tag: nil, tokens: val[0]}] result end .,., -module_eval(<<'.,.,', 'parser.y', 275) - def _reduce_87(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 274) + def _reduce_88(val, _values, result) result = [{tag: val[0], tokens: val[1]}] result end .,., -module_eval(<<'.,.,', 'parser.y', 276) - def _reduce_88(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 275) + def _reduce_89(val, _values, result) result = val[0].append({tag: val[1], tokens: val[2]}) result end .,., -module_eval(<<'.,.,', 'parser.y', 278) - def _reduce_89(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 277) + def _reduce_90(val, _values, result) on_action_error("ident after %prec", val[0]) if @prec_seen result end .,., -module_eval(<<'.,.,', 'parser.y', 279) - def _reduce_90(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 278) + def _reduce_91(val, _values, result) on_action_error("char after %prec", val[0]) if @prec_seen result end .,., -# reduce 91 omitted - # reduce 92 omitted # reduce 93 omitted # reduce 94 omitted -module_eval(<<'.,.,', 'parser.y', 287) - def _reduce_95(val, _values, result) +# reduce 95 omitted + +module_eval(<<'.,.,', 'parser.y', 286) + def _reduce_96(val, _values, result) lhs = val[0] lhs.alias_name = val[1] val[3].each do |builder| @@ -1876,8 +1880,8 @@ def _reduce_95(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 298) - def _reduce_96(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 297) + def _reduce_97(val, _values, result) builder = val[0] if !builder.line builder.line = @lexer.line - 1 @@ -1888,8 +1892,8 @@ def _reduce_96(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 306) - def _reduce_97(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 305) + def _reduce_98(val, _values, result) builder = val[2] if !builder.line builder.line = @lexer.line - 1 @@ -1900,8 +1904,8 @@ def _reduce_97(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 315) - def _reduce_98(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 314) + def _reduce_99(val, _values, result) reset_precs result = @grammar.create_rule_builder(@rule_counter, @midrule_action_counter) @@ -1909,8 +1913,8 @@ def _reduce_98(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 320) - def _reduce_99(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 319) + def _reduce_100(val, _values, result) token = val[1] token.alias_name = val[2] builder = val[0] @@ -1921,8 +1925,8 @@ def _reduce_99(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 328) - def _reduce_100(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 327) + def _reduce_101(val, _values, result) token = Lrama::Lexer::Token::InstantiateRule.new(s_value: val[2], alias_name: val[3], location: @lexer.location, args: [val[1]], lhs_tag: val[4]) builder = val[0] builder.add_rhs(token) @@ -1933,8 +1937,8 @@ def _reduce_100(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 336) - def _reduce_101(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 335) + def _reduce_102(val, _values, result) token = Lrama::Lexer::Token::InstantiateRule.new(s_value: val[1].s_value, alias_name: val[5], location: @lexer.location, args: val[3], lhs_tag: val[6]) builder = val[0] builder.add_rhs(token) @@ -1945,8 +1949,8 @@ def _reduce_101(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 344) - def _reduce_102(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 343) + def _reduce_103(val, _values, result) user_code = val[1] user_code.alias_name = val[2] user_code.tag = val[3] @@ -1958,8 +1962,8 @@ def _reduce_102(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 353) - def _reduce_103(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 352) + def _reduce_104(val, _values, result) sym = @grammar.find_symbol_by_id!(val[2]) @prec_seen = true builder = val[0] @@ -1970,57 +1974,57 @@ def _reduce_103(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 360) - def _reduce_104(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 359) + def _reduce_105(val, _values, result) result = "option" result end .,., -module_eval(<<'.,.,', 'parser.y', 361) - def _reduce_105(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 360) + def _reduce_106(val, _values, result) result = "nonempty_list" result end .,., -module_eval(<<'.,.,', 'parser.y', 362) - def _reduce_106(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 361) + def _reduce_107(val, _values, result) result = "list" result end .,., -module_eval(<<'.,.,', 'parser.y', 364) - def _reduce_107(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 363) + def _reduce_108(val, _values, result) result = [val[0]] result end .,., -module_eval(<<'.,.,', 'parser.y', 365) - def _reduce_108(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 364) + def _reduce_109(val, _values, result) result = val[0].append(val[2]) result end .,., -module_eval(<<'.,.,', 'parser.y', 366) - def _reduce_109(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 365) + def _reduce_110(val, _values, result) result = [Lrama::Lexer::Token::InstantiateRule.new(s_value: val[1].s_value, location: @lexer.location, args: val[0])] result end .,., -module_eval(<<'.,.,', 'parser.y', 367) - def _reduce_110(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 366) + def _reduce_111(val, _values, result) result = [Lrama::Lexer::Token::InstantiateRule.new(s_value: val[0].s_value, location: @lexer.location, args: val[2])] result end .,., -module_eval(<<'.,.,', 'parser.y', 371) - def _reduce_111(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 370) + def _reduce_112(val, _values, result) if @prec_seen on_action_error("multiple User_code after %prec", val[0]) if @code_after_prec @code_after_prec = true @@ -2031,31 +2035,31 @@ def _reduce_111(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 379) - def _reduce_112(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 378) + def _reduce_113(val, _values, result) end_c_declaration result end .,., -module_eval(<<'.,.,', 'parser.y', 383) - def _reduce_113(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 382) + def _reduce_114(val, _values, result) result = val[2] result end .,., -module_eval(<<'.,.,', 'parser.y', 386) - def _reduce_114(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 385) + def _reduce_115(val, _values, result) result = val[1].s_value result end .,., -module_eval(<<'.,.,', 'parser.y', 390) - def _reduce_115(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 389) + def _reduce_116(val, _values, result) begin_c_declaration('\Z') @grammar.epilogue_first_lineno = @lexer.line + 1 @@ -2063,8 +2067,8 @@ def _reduce_115(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 395) - def _reduce_116(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 394) + def _reduce_117(val, _values, result) end_c_declaration @grammar.epilogue = val[2].s_value @@ -2072,8 +2076,6 @@ def _reduce_116(val, _values, result) end .,., -# reduce 117 omitted - # reduce 118 omitted # reduce 119 omitted @@ -2090,8 +2092,10 @@ def _reduce_116(val, _values, result) # reduce 125 omitted -module_eval(<<'.,.,', 'parser.y', 412) - def _reduce_126(val, _values, result) +# reduce 126 omitted + +module_eval(<<'.,.,', 'parser.y', 411) + def _reduce_127(val, _values, result) result = Lrama::Lexer::Token::Ident.new(s_value: val[0]) result end diff --git a/parser.y b/parser.y index 52603a72..1ca2be46 100644 --- a/parser.y +++ b/parser.y @@ -250,8 +250,7 @@ rule result = builder } - alias: # empty - | string_as_id { result = val[0].s_value } + alias: string_as_id? { result = val[0].s_value if val[0] } symbol_declarations: symbol+ { result = [{tag: nil, tokens: val[0]}] } | TAG symbol+ { result = [{tag: val[0], tokens: val[1]}] }