diff --git a/lib/lrama/parser.rb b/lib/lrama/parser.rb index a6bfe511..9a8a896e 100644 --- a/lib/lrama/parser.rb +++ b/lib/lrama/parser.rb @@ -737,30 +737,30 @@ def raise_parse_error(error_message, location) 3, 50, 181, 165, 70, 51, 8, 50, 181, 79, 75, 51, 6, 50, 7, 161, 82, 47, 51, 51, 50, 50, 89, 82, 82, 166, 41, 51, 100, 50, - 182, 166, 82, 51, 48, 50, 182, 23, 25, 26, + 182, 166, 82, 51, 48, 50, 182, 21, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 47, 51, 51, 50, 50, 93, 79, 197, + 37, 38, 39, 47, 51, 51, 50, 50, 93, 79, + 197, 51, 51, 50, 50, 79, 197, 51, 51, 50, + 50, 79, 197, 21, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 9, + 51, 54, 50, 12, 13, 14, 15, 16, 17, 54, + 54, 18, 19, 20, 21, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 51, 51, 50, 50, 79, 197, 51, 51, 50, 50, - 79, 197, 23, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 9, 51, 54, - 50, 14, 15, 16, 17, 18, 19, 54, 54, 20, - 21, 22, 23, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 51, 51, - 50, 50, 79, 197, 51, 51, 50, 50, 79, 197, - 51, 51, 50, 50, 79, 197, 51, 51, 50, 50, - 79, 79, 51, 51, 50, 50, 79, 79, 51, 51, - 50, 50, 79, 79, 51, 51, 50, 207, 79, 79, - 51, 51, 207, 207, 79, 79, 51, 51, 50, 50, - 79, 187, 188, 189, 96, 187, 188, 189, 96, 217, - 221, 229, 218, 218, 218, 51, 51, 50, 50, 187, - 188, 189, 57, 58, 59, 60, 61, 62, 63, 64, - 65, 66, 67, 90, 94, 96, 101, 101, 101, 103, - 109, 113, 114, 117, 117, 117, 117, 120, 47, 124, - 125, 127, 129, 130, 131, 132, 133, 136, 140, 141, - 142, 143, 146, 147, 148, 150, 160, 168, 170, 171, - 172, 173, 174, 176, 177, 178, 146, 184, 192, 193, - 200, 160, 204, 176, 211, 160, 215, 216, 178, 176, - 226, 176, 228, 96, 96, 176 ] + 79, 197, 51, 51, 50, 50, 79, 197, 51, 51, + 50, 50, 79, 79, 51, 51, 50, 50, 79, 79, + 51, 51, 50, 50, 79, 79, 51, 51, 50, 207, + 79, 79, 51, 51, 207, 207, 79, 79, 51, 51, + 50, 50, 79, 187, 188, 189, 96, 187, 188, 189, + 96, 217, 221, 229, 218, 218, 218, 51, 51, 50, + 50, 187, 188, 189, 57, 58, 59, 60, 61, 62, + 63, 64, 65, 66, 67, 90, 94, 96, 101, 101, + 101, 103, 109, 113, 114, 117, 117, 117, 117, 120, + 47, 124, 125, 127, 129, 130, 131, 132, 133, 136, + 140, 141, 142, 143, 146, 147, 148, 150, 160, 168, + 170, 171, 172, 173, 174, 176, 177, 178, 146, 184, + 192, 193, 200, 160, 204, 176, 211, 160, 215, 216, + 178, 176, 226, 176, 228, 96, 96, 176 ] racc_action_check = [ 49, 145, 49, 145, 39, 145, 159, 183, 159, 183, @@ -768,97 +768,97 @@ def raise_parse_error(error_message, location) 1, 33, 159, 183, 33, 34, 3, 34, 201, 34, 34, 35, 2, 35, 2, 144, 35, 9, 36, 37, 36, 37, 39, 36, 37, 145, 7, 38, 49, 38, - 159, 183, 38, 15, 14, 15, 201, 9, 9, 9, + 159, 183, 38, 13, 12, 13, 201, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 42, 69, 172, 69, 172, 42, 172, 172, - 173, 70, 173, 70, 173, 173, 174, 81, 174, 81, - 174, 174, 42, 42, 42, 42, 42, 42, 42, 42, - 42, 42, 42, 42, 42, 42, 42, 4, 82, 16, - 82, 4, 4, 4, 4, 4, 4, 17, 18, 4, + 9, 9, 9, 42, 69, 172, 69, 172, 42, 172, + 172, 173, 70, 173, 70, 173, 173, 174, 81, 174, + 81, 174, 174, 42, 42, 42, 42, 42, 42, 42, + 42, 42, 42, 42, 42, 42, 42, 42, 42, 4, + 82, 14, 82, 4, 4, 4, 4, 4, 4, 15, + 16, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 194, 109, - 194, 109, 194, 194, 198, 111, 198, 111, 198, 198, - 199, 117, 199, 117, 199, 199, 74, 75, 74, 75, - 74, 75, 114, 116, 114, 116, 114, 116, 137, 166, - 137, 166, 137, 166, 182, 184, 182, 184, 182, 184, - 204, 216, 204, 216, 204, 216, 218, 119, 218, 119, - 218, 164, 164, 164, 164, 179, 179, 179, 179, 208, - 214, 223, 208, 214, 223, 134, 138, 134, 138, 209, - 209, 209, 19, 20, 23, 25, 26, 27, 28, 29, - 30, 31, 32, 40, 45, 46, 53, 55, 56, 57, - 68, 72, 73, 80, 85, 86, 87, 88, 89, 95, - 96, 102, 104, 105, 106, 107, 108, 112, 120, 121, - 122, 123, 124, 125, 126, 128, 141, 149, 151, 152, - 153, 154, 155, 156, 157, 158, 161, 163, 167, 169, - 175, 178, 180, 186, 190, 200, 205, 207, 213, 217, - 220, 221, 222, 226, 228, 230 ] + 194, 109, 194, 109, 194, 194, 198, 111, 198, 111, + 198, 198, 199, 117, 199, 117, 199, 199, 74, 75, + 74, 75, 74, 75, 114, 116, 114, 116, 114, 116, + 137, 166, 137, 166, 137, 166, 182, 184, 182, 184, + 182, 184, 204, 216, 204, 216, 204, 216, 218, 119, + 218, 119, 218, 164, 164, 164, 164, 179, 179, 179, + 179, 208, 214, 223, 208, 214, 223, 134, 138, 134, + 138, 209, 209, 209, 17, 18, 21, 25, 26, 27, + 28, 29, 30, 31, 32, 40, 45, 46, 53, 55, + 56, 57, 68, 72, 73, 80, 85, 86, 87, 88, + 89, 95, 96, 102, 104, 105, 106, 107, 108, 112, + 120, 121, 122, 123, 124, 125, 126, 128, 141, 149, + 151, 152, 153, 154, 155, 156, 157, 158, 161, 163, + 167, 169, 175, 178, 180, 186, 190, 200, 205, 207, + 213, 217, 220, 221, 222, 226, 228, 230 ] racc_action_pointer = [ - nil, 20, 22, 26, 98, nil, nil, 39, nil, 33, - nil, nil, nil, nil, 48, 50, 90, 98, 99, 207, - 194, nil, nil, 195, nil, 196, 197, 198, 213, 214, - 215, 216, 217, 16, 22, 28, 35, 36, 44, -1, - 221, nil, 68, nil, nil, 201, 174, nil, nil, -5, - nil, nil, nil, 207, nil, 208, 209, 210, nil, nil, - nil, nil, nil, nil, nil, nil, nil, nil, 222, 70, - 78, nil, 225, 224, 153, 154, nil, nil, nil, nil, - 225, 84, 105, nil, nil, 226, 227, 228, 197, 234, - nil, nil, nil, nil, nil, 197, 235, nil, nil, nil, - nil, nil, 239, nil, 240, 241, 242, 243, 244, 136, - nil, 142, 240, nil, 159, nil, 160, 148, nil, 184, - 243, 207, 239, 249, 206, 201, 252, nil, 253, nil, - nil, nil, nil, nil, 202, nil, nil, 165, 203, -26, - nil, 210, nil, nil, -10, -2, nil, nil, nil, 237, - nil, 238, 239, 240, 241, 242, 255, 259, 220, 3, - nil, 220, nil, 227, 143, nil, 166, 248, nil, 249, - nil, nil, 71, 77, 83, 228, nil, nil, 225, 147, - 232, nil, 171, 4, 172, nil, 265, nil, nil, nil, - 272, nil, nil, nil, 135, nil, nil, nil, 141, 147, - 229, 9, nil, nil, 177, 274, nil, 237, 158, 161, - nil, nil, nil, 233, 159, nil, 178, 271, 183, nil, - 260, 273, 262, 160, nil, nil, 232, nil, 233, nil, - 277, nil, nil ] + nil, 20, 22, 26, 100, nil, nil, 39, nil, 33, + nil, nil, 48, 50, 92, 100, 101, 209, 196, nil, + nil, 197, nil, nil, nil, 198, 199, 200, 215, 216, + 217, 218, 219, 16, 22, 28, 35, 36, 44, -1, + 223, nil, 69, nil, nil, 203, 176, nil, nil, -5, + nil, nil, nil, 209, nil, 210, 211, 212, nil, nil, + nil, nil, nil, nil, nil, nil, nil, nil, 224, 71, + 79, nil, 227, 226, 155, 156, nil, nil, nil, nil, + 227, 85, 107, nil, nil, 228, 229, 230, 199, 236, + nil, nil, nil, nil, nil, 199, 237, nil, nil, nil, + nil, nil, 241, nil, 242, 243, 244, 245, 246, 138, + nil, 144, 242, nil, 161, nil, 162, 150, nil, 186, + 245, 209, 241, 251, 208, 203, 254, nil, 255, nil, + nil, nil, nil, nil, 204, nil, nil, 167, 205, -26, + nil, 212, nil, nil, -10, -2, nil, nil, nil, 239, + nil, 240, 241, 242, 243, 244, 257, 261, 222, 3, + nil, 222, nil, 229, 145, nil, 168, 250, nil, 251, + nil, nil, 72, 78, 84, 230, nil, nil, 227, 149, + 234, nil, 173, 4, 174, nil, 267, nil, nil, nil, + 274, nil, nil, nil, 137, nil, nil, nil, 143, 149, + 231, 9, nil, nil, 179, 276, nil, 239, 160, 163, + nil, nil, nil, 235, 161, nil, 180, 273, 185, nil, + 262, 275, 264, 162, nil, nil, 234, nil, 235, nil, + 279, nil, nil ] racc_action_default = [ -2, -138, -8, -138, -138, -3, -4, -138, 233, -138, - -9, -10, -11, -12, -138, -138, -138, -138, -138, -138, - -138, -24, -25, -138, -29, -138, -138, -138, -138, -138, + -9, -10, -138, -138, -138, -138, -138, -138, -138, -22, + -23, -138, -27, -28, -29, -138, -138, -138, -138, -138, -138, -138, -138, -138, -138, -138, -138, -138, -138, -138, - -138, -7, -123, -96, -98, -138, -120, -122, -13, -127, - -94, -95, -126, -15, -85, -16, -17, -138, -21, -26, + -138, -7, -123, -96, -98, -138, -120, -122, -11, -127, + -94, -95, -126, -13, -85, -14, -15, -138, -19, -24, -30, -33, -36, -39, -40, -41, -42, -43, -44, -50, -138, -53, -71, -45, -75, -138, -78, -80, -81, -135, -46, -88, -138, -91, -93, -47, -48, -49, -138, -138, - -5, -1, -97, -124, -99, -138, -138, -14, -128, -129, - -130, -82, -138, -18, -138, -138, -138, -138, -138, -138, + -5, -1, -97, -124, -99, -138, -138, -12, -128, -129, + -130, -82, -138, -16, -138, -138, -138, -138, -138, -138, -54, -51, -73, -72, -138, -79, -76, -138, -92, -89, - -138, -138, -138, -138, -104, -138, -138, -86, -138, -22, - -27, -31, -34, -37, -52, -55, -74, -77, -90, -138, + -138, -138, -138, -138, -104, -138, -138, -86, -138, -20, + -25, -31, -34, -37, -52, -55, -74, -77, -90, -138, -58, -62, -6, -125, -100, -101, -105, -121, -83, -138, - -19, -138, -138, -138, -138, -138, -136, -138, -57, -60, + -17, -138, -138, -138, -138, -138, -136, -138, -57, -60, -63, -104, -103, -94, -120, -109, -138, -138, -87, -138, - -23, -28, -138, -138, -138, -138, -137, -59, -62, -120, + -21, -26, -138, -138, -138, -138, -137, -59, -62, -120, -94, -67, -138, -102, -138, -106, -136, -113, -114, -115, - -138, -112, -84, -20, -32, -131, -133, -134, -35, -38, + -138, -112, -84, -18, -32, -131, -133, -134, -35, -38, -62, -61, -64, -65, -138, -138, -70, -94, -138, -116, -107, -110, -132, -56, -138, -68, -138, -136, -138, -118, -138, -136, -138, -138, -108, -117, -120, -66, -120, -119, -136, -69, -111 ] racc_goto_table = [ - 76, 95, 69, 52, 74, 158, 110, 175, 118, 119, - 145, 208, 1, 212, 186, 2, 43, 212, 212, 4, - 42, 72, 91, 84, 84, 84, 84, 5, 40, 203, - 122, 214, 80, 85, 86, 87, 10, 210, 11, 111, - 115, 76, 12, 223, 138, 116, 118, 183, 110, 92, - 53, 55, 56, 194, 198, 199, 13, 72, 72, 219, - 49, 97, 128, 169, 213, 118, 104, 151, 224, 84, - 84, 110, 227, 105, 152, 106, 153, 107, 134, 154, - 76, 232, 115, 108, 137, 155, 68, 73, 112, 135, - 139, 121, 201, 205, 222, 126, 167, 72, 102, 72, - 149, 144, 190, 115, 220, 84, 123, 84, nil, nil, + 76, 95, 52, 74, 175, 69, 186, 110, 158, 118, + 119, 145, 212, 43, 1, 2, 212, 212, 208, 4, + 42, 203, 72, 91, 84, 84, 84, 84, 80, 85, + 86, 87, 5, 40, 210, 53, 55, 56, 214, 122, + 115, 76, 111, 10, 116, 138, 92, 118, 183, 110, + 223, 219, 194, 198, 199, 11, 49, 97, 72, 72, + 128, 169, 104, 151, 105, 224, 118, 213, 152, 227, + 84, 84, 110, 106, 153, 107, 154, 108, 232, 155, + 76, 134, 115, 137, 68, 73, 112, 135, 139, 121, + 201, 205, 222, 126, 167, 102, 149, 144, 72, 190, + 72, 220, 123, 115, nil, nil, 84, nil, 84, nil, nil, 164, nil, nil, nil, nil, nil, nil, nil, 185, - nil, nil, 72, nil, nil, 179, 84, nil, nil, nil, + nil, nil, nil, 72, nil, 179, nil, 84, nil, nil, nil, nil, 191, nil, 202, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 206, 164, 209, nil, nil, nil, nil, nil, nil, nil, nil, nil, @@ -867,19 +867,19 @@ def raise_parse_error(error_message, location) nil, 230, 209, 231, 225 ] racc_goto_check = [ - 43, 44, 33, 35, 49, 40, 34, 39, 56, 55, - 60, 46, 1, 64, 45, 2, 57, 64, 64, 3, - 4, 35, 5, 35, 35, 35, 35, 6, 7, 45, - 8, 46, 32, 32, 32, 32, 9, 39, 10, 33, - 43, 43, 11, 46, 55, 49, 56, 60, 34, 57, - 15, 15, 15, 21, 21, 21, 12, 35, 35, 45, - 13, 14, 16, 17, 40, 56, 18, 19, 39, 35, - 35, 34, 39, 22, 23, 24, 25, 26, 33, 27, - 43, 39, 43, 28, 49, 29, 30, 31, 36, 37, - 38, 41, 42, 47, 48, 51, 52, 35, 53, 35, - 54, 59, 61, 43, 62, 35, 63, 35, nil, nil, + 43, 44, 35, 49, 39, 33, 45, 34, 40, 56, + 55, 60, 64, 57, 1, 2, 64, 64, 46, 3, + 4, 45, 35, 5, 35, 35, 35, 35, 32, 32, + 32, 32, 6, 7, 39, 13, 13, 13, 46, 8, + 43, 43, 33, 9, 49, 55, 57, 56, 60, 34, + 46, 45, 21, 21, 21, 10, 11, 12, 35, 35, + 14, 15, 16, 17, 22, 39, 56, 40, 23, 39, + 35, 35, 34, 24, 25, 26, 27, 28, 39, 29, + 43, 33, 43, 49, 30, 31, 36, 37, 38, 41, + 42, 47, 48, 51, 52, 53, 54, 59, 35, 61, + 35, 62, 63, 43, nil, nil, 35, nil, 35, nil, nil, 43, nil, nil, nil, nil, nil, nil, nil, 44, - nil, nil, 35, nil, nil, 43, 35, nil, nil, nil, + nil, nil, nil, 35, nil, 43, nil, 35, nil, nil, nil, nil, 43, nil, 44, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 43, 43, 43, nil, nil, nil, nil, nil, nil, nil, nil, nil, @@ -888,17 +888,17 @@ def raise_parse_error(error_message, location) nil, 44, 43, 44, 43 ] racc_goto_pointer = [ - nil, 12, 15, 17, 11, -20, 25, 22, -60, 32, - 34, 38, 52, 45, 12, 34, -41, -87, 8, -62, - nil, -119, 14, -56, 15, -55, 16, -53, 21, -48, - 53, 53, -3, -31, -63, -12, 16, -23, -30, -149, - -136, 2, -86, -34, -45, -150, -173, -88, -121, -30, - nil, -6, -52, 44, -27, -73, -73, 7, nil, -23, - -114, -63, -107, 13, -181 ] + nil, 14, 15, 17, 11, -19, 30, 27, -51, 39, + 51, 43, 8, 21, -43, -89, 4, -66, nil, nil, + nil, -120, 5, -62, 13, -57, 14, -56, 15, -54, + 51, 51, -7, -28, -62, -11, 14, -25, -32, -152, + -133, 0, -88, -34, -45, -158, -166, -90, -123, -31, + nil, -8, -54, 41, -31, -72, -72, 4, nil, -27, + -113, -66, -110, 9, -182 ] racc_goto_default = [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - 45, nil, nil, nil, nil, nil, nil, nil, nil, nil, + 45, nil, nil, nil, nil, nil, nil, nil, 22, 23, 24, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 71, 77, nil, nil, nil, nil, nil, 46, 159, 196, nil, nil, nil, nil, nil, nil, @@ -917,24 +917,24 @@ def raise_parse_error(error_message, location) 0, 57, :_reduce_8, 2, 57, :_reduce_none, 1, 63, :_reduce_none, - 1, 63, :_reduce_none, - 1, 63, :_reduce_none, - 2, 63, :_reduce_13, + 2, 63, :_reduce_11, 3, 63, :_reduce_none, 2, 63, :_reduce_none, - 2, 63, :_reduce_16, - 2, 63, :_reduce_17, - 0, 70, :_reduce_18, - 0, 71, :_reduce_19, - 7, 63, :_reduce_20, - 0, 72, :_reduce_21, - 0, 73, :_reduce_22, - 6, 63, :_reduce_23, - 1, 63, :_reduce_24, + 2, 63, :_reduce_14, + 2, 63, :_reduce_15, + 0, 68, :_reduce_16, + 0, 69, :_reduce_17, + 7, 63, :_reduce_18, + 0, 70, :_reduce_19, + 0, 71, :_reduce_20, + 6, 63, :_reduce_21, + 1, 63, :_reduce_22, 1, 63, :_reduce_none, - 0, 76, :_reduce_26, - 0, 77, :_reduce_27, - 6, 64, :_reduce_28, + 0, 76, :_reduce_24, + 0, 77, :_reduce_25, + 6, 64, :_reduce_26, + 1, 64, :_reduce_none, + 1, 64, :_reduce_none, 1, 64, :_reduce_none, 0, 78, :_reduce_30, 0, 79, :_reduce_31, @@ -950,20 +950,20 @@ def raise_parse_error(error_message, location) 2, 64, :_reduce_41, 2, 64, :_reduce_42, 2, 64, :_reduce_43, - 2, 74, :_reduce_none, - 2, 74, :_reduce_45, - 2, 74, :_reduce_46, - 2, 74, :_reduce_47, - 2, 74, :_reduce_48, - 2, 74, :_reduce_49, + 2, 72, :_reduce_none, + 2, 72, :_reduce_45, + 2, 72, :_reduce_46, + 2, 72, :_reduce_47, + 2, 72, :_reduce_48, + 2, 72, :_reduce_49, 1, 84, :_reduce_50, 2, 84, :_reduce_51, 3, 84, :_reduce_52, 1, 87, :_reduce_53, 2, 87, :_reduce_54, 3, 88, :_reduce_55, - 8, 65, :_reduce_56, - 5, 66, :_reduce_57, + 8, 73, :_reduce_56, + 5, 74, :_reduce_57, 1, 92, :_reduce_58, 3, 92, :_reduce_59, 1, 94, :_reduce_60, @@ -990,10 +990,10 @@ def raise_parse_error(error_message, location) 1, 97, :_reduce_none, 0, 105, :_reduce_82, 0, 106, :_reduce_83, - 6, 69, :_reduce_84, + 6, 67, :_reduce_84, 0, 107, :_reduce_85, 0, 108, :_reduce_86, - 5, 69, :_reduce_87, + 5, 67, :_reduce_87, 1, 86, :_reduce_88, 2, 86, :_reduce_89, 3, 86, :_reduce_90, @@ -1032,11 +1032,11 @@ def raise_parse_error(error_message, location) 0, 59, :_reduce_none, 0, 117, :_reduce_124, 3, 59, :_reduce_125, - 1, 67, :_reduce_none, - 0, 68, :_reduce_none, - 1, 68, :_reduce_none, - 1, 68, :_reduce_none, - 1, 68, :_reduce_none, + 1, 65, :_reduce_none, + 0, 66, :_reduce_none, + 1, 66, :_reduce_none, + 1, 66, :_reduce_none, + 1, 66, :_reduce_none, 1, 75, :_reduce_131, 2, 75, :_reduce_132, 1, 118, :_reduce_none, @@ -1192,8 +1192,6 @@ def raise_parse_error(error_message, location) "@2", "bison_declaration", "grammar_declaration", - "rule_declaration", - "inline_declaration", "variable", "value", "params", @@ -1202,6 +1200,8 @@ def raise_parse_error(error_message, location) "@5", "@6", "symbol_declaration", + "rule_declaration", + "inline_declaration", "generic_symlist", "@7", "@8", @@ -1298,23 +1298,19 @@ def _reduce_8(val, _values, result) # reduce 10 omitted -# reduce 11 omitted - -# reduce 12 omitted - -module_eval(<<'.,.,', 'parser.y', 33) - def _reduce_13(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 31) + def _reduce_11(val, _values, result) @grammar.expect = val[1] result end .,., -# reduce 14 omitted +# reduce 12 omitted -# reduce 15 omitted +# reduce 13 omitted -module_eval(<<'.,.,', 'parser.y', 38) - def _reduce_16(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 36) + def _reduce_14(val, _values, result) val[1].each {|token| @grammar.lex_param = Grammar::Code::NoReferenceCode.new(type: :lex_param, token_code: token).token_code.s_value } @@ -1323,8 +1319,8 @@ def _reduce_16(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 44) - def _reduce_17(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 42) + def _reduce_15(val, _values, result) val[1].each {|token| @grammar.parse_param = Grammar::Code::NoReferenceCode.new(type: :parse_param, token_code: token).token_code.s_value } @@ -1333,81 +1329,81 @@ def _reduce_17(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 50) - def _reduce_18(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 48) + def _reduce_16(val, _values, result) begin_c_declaration("}") result end .,., -module_eval(<<'.,.,', 'parser.y', 54) - def _reduce_19(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 52) + def _reduce_17(val, _values, result) end_c_declaration result end .,., -module_eval(<<'.,.,', 'parser.y', 58) - def _reduce_20(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 56) + def _reduce_18(val, _values, result) @grammar.add_percent_code(id: val[1], code: val[4]) result end .,., -module_eval(<<'.,.,', 'parser.y', 62) - def _reduce_21(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 60) + def _reduce_19(val, _values, result) begin_c_declaration("}") result end .,., -module_eval(<<'.,.,', 'parser.y', 66) - def _reduce_22(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 64) + def _reduce_20(val, _values, result) end_c_declaration result end .,., -module_eval(<<'.,.,', 'parser.y', 70) - def _reduce_23(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 68) + def _reduce_21(val, _values, result) @grammar.initial_action = Grammar::Code::InitialActionCode.new(type: :initial_action, token_code: val[3]) result end .,., -module_eval(<<'.,.,', 'parser.y', 72) - def _reduce_24(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 70) + def _reduce_22(val, _values, result) @grammar.no_stdlib = true result end .,., -# reduce 25 omitted +# reduce 23 omitted -module_eval(<<'.,.,', 'parser.y', 77) - def _reduce_26(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 75) + def _reduce_24(val, _values, result) begin_c_declaration("}") result end .,., -module_eval(<<'.,.,', 'parser.y', 81) - def _reduce_27(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 79) + def _reduce_25(val, _values, result) end_c_declaration result end .,., -module_eval(<<'.,.,', 'parser.y', 85) - def _reduce_28(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 83) + def _reduce_26(val, _values, result) @grammar.set_union( Grammar::Code::NoReferenceCode.new(type: :union, token_code: val[3]), val[3].line @@ -1417,6 +1413,10 @@ def _reduce_28(val, _values, result) end .,., +# reduce 27 omitted + +# reduce 28 omitted + # reduce 29 omitted module_eval(<<'.,.,', 'parser.y', 93) diff --git a/parser.y b/parser.y index 59bc00af..5d49e7ed 100644 --- a/parser.y +++ b/parser.y @@ -29,8 +29,6 @@ rule | bison_declarations bison_declaration bison_declaration: grammar_declaration - | rule_declaration - | inline_declaration | "%expect" INTEGER { @grammar.expect = val[1] } | "%define" variable value | "%param" params @@ -89,6 +87,8 @@ rule ) } | symbol_declaration + | rule_declaration + | inline_declaration | "%destructor" "{" { begin_c_declaration("}") diff --git a/spec/fixtures/inlining/basic.y b/spec/fixtures/inlining/basic.y index 9fe55314..1db03da3 100644 --- a/spec/fixtures/inlining/basic.y +++ b/spec/fixtures/inlining/basic.y @@ -25,8 +25,14 @@ static int yyerror(YYLTYPE *loc, const char *str); expression : NUM | expression op expression { $$ = $1 $2 $3; } + | expression other_op expression { $$ = $1 $2 $3; } ; + +%rule %inline other_op : '%' { + 1 + } + | '&' { - 1 - } + ; + %% static int yylex(YYSTYPE *yylval, YYLTYPE *loc) diff --git a/spec/fixtures/parameterizing_rules/user_defined/basic.y b/spec/fixtures/parameterizing_rules/user_defined/basic.y index dc8279ab..fb62f5fe 100644 --- a/spec/fixtures/parameterizing_rules/user_defined/basic.y +++ b/spec/fixtures/parameterizing_rules/user_defined/basic.y @@ -21,8 +21,13 @@ static int yyerror(YYLTYPE *loc, const char *str); %% program : defined_option(number) + | defined_list(number) ; +%rule defined_list(X): /* empty */ + | defined_list(X) number + ; + %% static int yylex(YYSTYPE *yylval, YYLTYPE *loc) diff --git a/spec/lrama/parser_spec.rb b/spec/lrama/parser_spec.rb index 2fddc68b..f5450f5b 100644 --- a/spec/lrama/parser_spec.rb +++ b/spec/lrama/parser_spec.rb @@ -1409,6 +1409,7 @@ Sym.new(id: T::Ident.new(s_value: "$accept"), alias_name: nil, number: 4, tag: nil, term: false, token_id: 0, nullable: false), Sym.new(id: T::Ident.new(s_value: "defined_option_number"), alias_name: nil, number: 5, tag: T::Tag.new(s_value: ""), term: false, token_id: 1, nullable: true), Sym.new(id: T::Ident.new(s_value: "program"), alias_name: nil, number: 6, tag: nil, term: false, token_id: 2, nullable: true), + Sym.new(id: T::Ident.new(s_value: "defined_list_number"), alias_name: nil, number: 7, tag: T::Tag.new(s_value: ""), term: false, token_id: 3, nullable: true), ]) expect(grammar.rules).to eq([ @@ -1457,6 +1458,40 @@ precedence_sym: nil, lineno: 23, ), + Rule.new( + id: 4, + lhs: grammar.find_symbol_by_s_value!("defined_list_number"), + rhs: [], + lhs_tag: T::Tag.new(s_value: ""), + token_code: nil, + nullable: true, + precedence_sym: nil, + lineno: 24, + ), + Rule.new( + id: 5, + lhs: grammar.find_symbol_by_s_value!("defined_list_number"), + rhs: [ + grammar.find_symbol_by_s_value!("defined_list_number"), + grammar.find_symbol_by_s_value!("number"), + ], + lhs_tag: T::Tag.new(s_value: ""), + token_code: nil, + nullable: false, + precedence_sym: grammar.find_symbol_by_s_value!("number"), + lineno: 24, + ), + Rule.new( + id: 6, + lhs: grammar.find_symbol_by_s_value!("program"), + rhs: [ + grammar.find_symbol_by_s_value!("defined_list_number"), + ], + token_code: nil, + nullable: true, + precedence_sym: nil, + lineno: 24, + ), ]) end end @@ -2303,8 +2338,8 @@ it "expands inlining rules" do expect(grammar.nterms.sort_by(&:number)).to match_symbols([ - Sym.new(id: T::Ident.new(s_value: "$accept"), alias_name: nil, number: 8, tag: nil, term: false, token_id: 0, nullable: false), - Sym.new(id: T::Ident.new(s_value: "expression"), alias_name: nil, number: 9, tag: T::Tag.new(s_value: ""), term: false, token_id: 1, nullable: false), + Sym.new(id: T::Ident.new(s_value: "$accept"), alias_name: nil, number: 10, tag: nil, term: false, token_id: 0, nullable: false), + Sym.new(id: T::Ident.new(s_value: "expression"), alias_name: nil, number: 11, tag: T::Tag.new(s_value: ""), term: false, token_id: 1, nullable: false), ]) expect(grammar.rules).to eq([ @@ -2383,6 +2418,32 @@ precedence_sym: grammar.find_symbol_by_s_value!("'/'"), lineno: 27, ), + Rule.new( + id: 6, + lhs: grammar.find_symbol_by_s_value!("expression"), + rhs: [ + grammar.find_symbol_by_s_value!("expression"), + grammar.find_symbol_by_s_value!("'%'"), + grammar.find_symbol_by_s_value!("expression"), + ], + token_code: T::UserCode.new(s_value: " $$ = $1 + 1 + $3; "), + nullable: false, + precedence_sym: grammar.find_symbol_by_s_value!("'%'"), + lineno: 28, + ), + Rule.new( + id: 7, + lhs: grammar.find_symbol_by_s_value!("expression"), + rhs: [ + grammar.find_symbol_by_s_value!("expression"), + grammar.find_symbol_by_s_value!("'&'"), + grammar.find_symbol_by_s_value!("expression"), + ], + token_code: T::UserCode.new(s_value: " $$ = $1 - 1 - $3; "), + nullable: false, + precedence_sym: grammar.find_symbol_by_s_value!("'&'"), + lineno: 28, + ), ]) end end