diff --git a/lib/lrama/parser.rb b/lib/lrama/parser.rb index 591aa9e4..27045924 100644 --- a/lib/lrama/parser.rb +++ b/lib/lrama/parser.rb @@ -733,112 +733,112 @@ def raise_parse_error(error_message, location) 71, 8, 161, 185, 169, 6, 52, 7, 51, 185, 80, 76, 40, 52, 52, 51, 51, 46, 83, 83, 47, 52, 90, 51, 49, 170, 83, 52, 102, 51, - 186, 170, 83, 52, 55, 51, 186, 22, 24, 25, + 186, 170, 83, 52, 55, 51, 186, 20, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 46, 52, 52, 51, 51, 94, 80, 202, + 36, 37, 38, 46, 52, 52, 51, 51, 94, 80, + 202, 52, 52, 51, 51, 80, 202, 52, 52, 51, + 51, 80, 202, 20, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 9, + 187, 46, 124, 161, 12, 13, 14, 15, 16, 17, + 55, 55, 18, 19, 20, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 52, 52, 51, 51, 80, 202, 52, 52, 51, 51, - 80, 202, 22, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 9, 187, 46, - 124, 161, 14, 15, 16, 17, 18, 19, 55, 55, - 20, 21, 22, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 52, 52, - 51, 51, 80, 202, 52, 52, 51, 51, 80, 202, - 52, 52, 51, 51, 80, 202, 52, 52, 51, 51, - 80, 80, 52, 52, 51, 51, 80, 80, 52, 52, - 51, 51, 80, 80, 52, 52, 51, 213, 80, 80, - 52, 52, 213, 213, 80, 80, 52, 52, 51, 51, - 80, 192, 193, 194, 98, 192, 193, 194, 98, 224, - 229, 237, 225, 225, 225, 52, 52, 51, 51, 52, - 58, 51, 192, 193, 194, 59, 60, 61, 62, 63, - 64, 65, 66, 67, 68, 91, 47, 96, 98, 103, - 103, 103, 105, 111, 114, 116, 119, 119, 119, 119, - 122, 127, 128, 130, 132, 133, 134, 135, 136, 80, - 143, 144, 145, 146, 147, 150, 151, 152, 154, 164, - 143, 166, 172, 174, 175, 176, 177, 178, 179, 181, - 182, 150, 189, 197, 198, 205, 164, 209, 212, 98, - 217, 164, 221, 164, 223, 179, 182, 182, 98, 234, - 179, 236, 179, 98, 98, 179 ] + 80, 202, 52, 52, 51, 51, 80, 202, 52, 52, + 51, 51, 80, 80, 52, 52, 51, 51, 80, 80, + 52, 52, 51, 51, 80, 80, 52, 52, 51, 213, + 80, 80, 52, 52, 213, 213, 80, 80, 52, 52, + 51, 51, 80, 192, 193, 194, 98, 192, 193, 194, + 98, 224, 229, 237, 225, 225, 225, 52, 52, 51, + 51, 52, 58, 51, 192, 193, 194, 59, 60, 61, + 62, 63, 64, 65, 66, 67, 68, 91, 47, 96, + 98, 103, 103, 103, 105, 111, 114, 116, 119, 119, + 119, 119, 122, 127, 128, 130, 132, 133, 134, 135, + 136, 80, 143, 144, 145, 146, 147, 150, 151, 152, + 154, 164, 143, 166, 172, 174, 175, 176, 177, 178, + 179, 181, 182, 150, 189, 197, 198, 205, 164, 209, + 212, 98, 217, 164, 221, 164, 223, 179, 182, 182, + 98, 234, 179, 236, 179, 98, 98, 179 ] racc_action_check = [ 50, 149, 50, 149, 38, 149, 163, 188, 163, 188, 163, 188, 206, 1, 206, 32, 206, 32, 149, 142, 32, 3, 142, 163, 188, 2, 33, 2, 33, 206, 33, 33, 7, 34, 35, 34, 35, 9, 34, 35, - 10, 36, 38, 36, 14, 149, 36, 37, 50, 37, - 163, 188, 37, 15, 16, 15, 206, 9, 9, 9, + 10, 36, 38, 36, 12, 149, 36, 37, 50, 37, + 163, 188, 37, 13, 14, 13, 206, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, - 9, 9, 41, 70, 176, 70, 176, 41, 176, 176, - 177, 71, 177, 71, 177, 177, 178, 82, 178, 82, - 178, 178, 41, 41, 41, 41, 41, 41, 41, 41, - 41, 41, 41, 41, 41, 41, 41, 4, 165, 90, - 90, 165, 4, 4, 4, 4, 4, 4, 17, 18, + 9, 9, 9, 41, 70, 176, 70, 176, 41, 176, + 176, 177, 71, 177, 71, 177, 177, 178, 82, 178, + 82, 178, 178, 41, 41, 41, 41, 41, 41, 41, + 41, 41, 41, 41, 41, 41, 41, 41, 41, 4, + 165, 90, 90, 165, 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, 199, 83, - 199, 83, 199, 199, 203, 111, 203, 111, 203, 203, - 204, 113, 204, 113, 204, 204, 75, 76, 75, 76, - 75, 76, 116, 118, 116, 118, 116, 118, 140, 170, - 140, 170, 140, 170, 186, 189, 186, 189, 186, 189, - 209, 223, 209, 223, 209, 223, 225, 119, 225, 119, - 225, 168, 168, 168, 168, 183, 183, 183, 183, 214, - 220, 231, 214, 220, 231, 121, 137, 121, 137, 141, - 19, 141, 215, 215, 215, 20, 22, 24, 25, 26, - 27, 28, 29, 30, 31, 39, 43, 44, 45, 54, - 56, 57, 58, 69, 73, 74, 81, 86, 87, 88, - 89, 97, 98, 104, 106, 107, 108, 109, 110, 115, - 122, 123, 124, 125, 126, 127, 128, 129, 131, 144, - 145, 148, 153, 155, 156, 157, 158, 159, 160, 161, - 162, 166, 167, 171, 173, 180, 182, 184, 187, 191, - 195, 205, 210, 212, 213, 216, 219, 222, 224, 228, - 229, 230, 232, 234, 236, 239 ] + 199, 83, 199, 83, 199, 199, 203, 111, 203, 111, + 203, 203, 204, 113, 204, 113, 204, 204, 75, 76, + 75, 76, 75, 76, 116, 118, 116, 118, 116, 118, + 140, 170, 140, 170, 140, 170, 186, 189, 186, 189, + 186, 189, 209, 223, 209, 223, 209, 223, 225, 119, + 225, 119, 225, 168, 168, 168, 168, 183, 183, 183, + 183, 214, 220, 231, 214, 220, 231, 121, 137, 121, + 137, 141, 17, 141, 215, 215, 215, 18, 20, 24, + 25, 26, 27, 28, 29, 30, 31, 39, 43, 44, + 45, 54, 56, 57, 58, 69, 73, 74, 81, 86, + 87, 88, 89, 97, 98, 104, 106, 107, 108, 109, + 110, 115, 122, 123, 124, 125, 126, 127, 128, 129, + 131, 144, 145, 148, 153, 155, 156, 157, 158, 159, + 160, 161, 162, 166, 167, 171, 173, 180, 182, 184, + 187, 191, 195, 205, 210, 212, 213, 216, 219, 222, + 224, 228, 229, 230, 232, 234, 236, 239 ] racc_action_pointer = [ - nil, 13, 15, 21, 98, nil, nil, 25, nil, 33, - 27, nil, nil, nil, 38, 50, 34, 98, 99, 205, - 195, nil, 196, nil, 197, 198, 199, 215, 216, 217, - 218, 219, 12, 23, 30, 31, 38, 44, -1, 223, - nil, 68, nil, 213, 214, 177, nil, nil, nil, nil, - -5, nil, nil, nil, 209, nil, 210, 211, 212, nil, - nil, nil, nil, nil, nil, nil, nil, nil, nil, 225, - 70, 78, nil, 228, 227, 153, 154, nil, nil, nil, - nil, 228, 84, 136, nil, nil, 229, 230, 231, 200, - 105, nil, nil, nil, nil, nil, nil, 199, 237, nil, - nil, nil, nil, nil, 241, nil, 242, 243, 244, 245, - 246, 142, nil, 148, nil, 242, 159, nil, 160, 184, - nil, 202, 245, 209, 212, 242, 252, 209, 204, 255, - nil, 256, nil, nil, nil, nil, nil, 203, nil, nil, - 165, 206, -22, nil, 213, 255, nil, nil, 216, -2, - nil, nil, nil, 241, nil, 242, 243, 244, 245, 246, - 260, 264, 225, 3, nil, 67, 225, 232, 143, nil, - 166, 252, nil, 253, nil, nil, 71, 77, 83, nil, - 233, nil, 230, 147, 237, nil, 171, 236, 4, 172, - nil, 228, nil, nil, nil, 278, nil, nil, nil, 135, - nil, nil, nil, 141, 147, 235, 9, nil, nil, 177, - 280, nil, 237, 244, 158, 164, 277, nil, nil, 241, - 159, nil, 242, 178, 237, 183, nil, nil, 268, 282, - 270, 160, 284, nil, 242, nil, 243, nil, nil, 287, + nil, 13, 15, 21, 100, nil, nil, 25, nil, 33, + 27, nil, 38, 50, 34, 100, 101, 207, 197, nil, + 198, nil, nil, nil, 199, 200, 201, 217, 218, 219, + 220, 221, 12, 23, 30, 31, 38, 44, -1, 225, + nil, 69, nil, 215, 216, 179, nil, nil, nil, nil, + -5, nil, nil, nil, 211, nil, 212, 213, 214, nil, + nil, nil, nil, nil, nil, nil, nil, nil, nil, 227, + 71, 79, nil, 230, 229, 155, 156, nil, nil, nil, + nil, 230, 85, 138, nil, nil, 231, 232, 233, 202, + 107, nil, nil, nil, nil, nil, nil, 201, 239, nil, + nil, nil, nil, nil, 243, nil, 244, 245, 246, 247, + 248, 144, nil, 150, nil, 244, 161, nil, 162, 186, + nil, 204, 247, 211, 214, 244, 254, 211, 206, 257, + nil, 258, nil, nil, nil, nil, nil, 205, nil, nil, + 167, 208, -22, nil, 215, 257, nil, nil, 218, -2, + nil, nil, nil, 243, nil, 244, 245, 246, 247, 248, + 262, 266, 227, 3, nil, 69, 227, 234, 145, nil, + 168, 254, nil, 255, nil, nil, 72, 78, 84, nil, + 235, nil, 232, 149, 239, nil, 173, 238, 4, 174, + nil, 230, nil, nil, nil, 280, nil, nil, nil, 137, + nil, nil, nil, 143, 149, 237, 9, nil, nil, 179, + 282, nil, 239, 246, 160, 166, 279, nil, nil, 243, + 161, nil, 244, 180, 239, 185, nil, nil, 270, 284, + 272, 162, 286, nil, 244, nil, 245, nil, nil, 289, nil, nil ] racc_action_default = [ -2, -139, -10, -139, -139, -3, -4, -139, 242, -139, - -8, -12, -13, -14, -139, -139, -139, -139, -139, -139, - -139, -26, -139, -30, -139, -139, -139, -139, -139, -139, + -8, -12, -139, -139, -139, -139, -139, -139, -139, -24, + -139, -28, -29, -30, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, -139, - -7, -126, -100, -8, -139, -123, -125, -9, -11, -15, - -130, -98, -99, -129, -17, -89, -18, -19, -139, -23, - -27, -31, -34, -37, -40, -41, -42, -43, -44, -45, + -7, -126, -100, -8, -139, -123, -125, -9, -11, -13, + -130, -98, -99, -129, -15, -89, -16, -17, -139, -21, + -25, -31, -34, -37, -40, -41, -42, -43, -44, -45, -51, -139, -54, -56, -46, -79, -139, -82, -84, -85, -138, -47, -92, -139, -95, -97, -48, -49, -50, -139, - -139, -5, -1, -101, -127, -102, -103, -139, -139, -16, - -131, -132, -133, -86, -139, -20, -139, -139, -139, -139, + -139, -5, -1, -101, -127, -102, -103, -139, -139, -14, + -131, -132, -133, -86, -139, -18, -139, -139, -139, -139, -139, -139, -55, -52, -57, -77, -139, -83, -80, -139, -96, -93, -139, -139, -139, -139, -139, -107, -139, -139, - -90, -139, -24, -28, -32, -35, -38, -53, -58, -78, + -90, -139, -22, -26, -32, -35, -38, -53, -58, -78, -81, -94, -139, -64, -68, -139, -6, -128, -104, -105, - -108, -124, -87, -139, -21, -139, -139, -139, -139, -139, + -108, -124, -87, -139, -19, -139, -139, -139, -139, -139, -59, -139, -62, -66, -69, -139, -107, -98, -123, -112, - -139, -139, -91, -139, -25, -29, -139, -139, -139, -60, + -139, -139, -91, -139, -23, -27, -139, -139, -139, -60, -139, -65, -68, -123, -98, -73, -139, -139, -106, -139, - -109, -123, -116, -117, -118, -139, -115, -88, -22, -33, + -109, -123, -116, -117, -118, -139, -115, -88, -20, -33, -134, -136, -137, -36, -39, -68, -67, -70, -71, -139, -139, -76, -68, -98, -139, -119, -59, -113, -135, -61, -139, -74, -63, -139, -123, -139, -121, -110, -139, -59, @@ -846,18 +846,18 @@ def raise_parse_error(error_message, location) -75, -114 ] racc_goto_table = [ - 77, 75, 97, 191, 112, 53, 162, 70, 180, 120, - 149, 214, 142, 1, 2, 121, 4, 41, 208, 48, - 92, 42, 73, 5, 85, 85, 85, 85, 218, 39, - 125, 220, 218, 218, 10, 165, 81, 86, 87, 88, - 11, 12, 117, 77, 118, 231, 113, 112, 120, 188, - 226, 141, 95, 93, 54, 56, 57, 199, 203, 204, - 73, 73, 13, 50, 227, 99, 131, 219, 120, 173, - 106, 112, 85, 85, 222, 155, 107, 235, 156, 108, - 238, 157, 109, 77, 140, 117, 137, 241, 158, 110, - 159, 69, 74, 138, 115, 123, 206, 210, 230, 139, - 129, 73, 171, 73, 104, 153, 148, 117, 195, 85, - 228, 85, 126, nil, nil, nil, 168, nil, nil, nil, + 77, 75, 97, 53, 112, 191, 162, 70, 180, 120, + 149, 214, 142, 1, 121, 54, 56, 57, 48, 2, + 208, 42, 73, 4, 85, 85, 85, 85, 218, 41, + 92, 220, 218, 218, 5, 165, 81, 86, 87, 88, + 39, 125, 117, 77, 118, 231, 113, 112, 120, 188, + 141, 95, 226, 93, 199, 203, 204, 10, 11, 50, + 73, 73, 99, 131, 227, 173, 106, 219, 120, 155, + 107, 112, 85, 85, 222, 156, 108, 235, 157, 109, + 238, 158, 110, 77, 140, 117, 137, 241, 159, 69, + 74, 138, 115, 123, 206, 210, 230, 139, 129, 171, + 104, 73, 153, 73, 148, 195, 228, 117, 126, 85, + nil, 85, nil, nil, nil, nil, 168, nil, nil, nil, nil, nil, nil, nil, nil, 190, nil, 73, nil, nil, 183, 85, nil, nil, nil, nil, nil, 196, nil, nil, 207, nil, nil, nil, nil, nil, nil, nil, 216, nil, @@ -868,18 +868,18 @@ def raise_parse_error(error_message, location) 215, 239, 233, 240 ] racc_goto_check = [ - 44, 51, 45, 46, 35, 36, 40, 34, 41, 57, - 61, 47, 39, 1, 2, 56, 3, 4, 46, 10, - 5, 58, 36, 6, 36, 36, 36, 36, 65, 7, - 8, 47, 65, 65, 9, 39, 33, 33, 33, 33, - 11, 12, 44, 44, 51, 47, 34, 35, 57, 61, - 46, 56, 10, 58, 16, 16, 16, 22, 22, 22, - 36, 36, 13, 14, 41, 15, 17, 40, 57, 18, - 19, 35, 36, 36, 40, 20, 23, 41, 24, 25, - 41, 26, 27, 44, 51, 44, 34, 41, 28, 29, - 30, 31, 32, 37, 38, 42, 43, 48, 49, 50, - 52, 36, 53, 36, 54, 55, 60, 44, 62, 36, - 63, 36, 64, nil, nil, nil, 44, nil, nil, nil, + 44, 51, 45, 36, 35, 46, 40, 34, 41, 57, + 61, 47, 39, 1, 56, 14, 14, 14, 10, 2, + 46, 58, 36, 3, 36, 36, 36, 36, 65, 4, + 5, 47, 65, 65, 6, 39, 33, 33, 33, 33, + 7, 8, 44, 44, 51, 47, 34, 35, 57, 61, + 56, 10, 46, 58, 22, 22, 22, 9, 11, 12, + 36, 36, 13, 15, 41, 16, 17, 40, 57, 18, + 23, 35, 36, 36, 40, 24, 25, 41, 26, 27, + 41, 28, 29, 44, 51, 44, 34, 41, 30, 31, + 32, 37, 38, 42, 43, 48, 49, 50, 52, 53, + 54, 36, 55, 36, 60, 62, 63, 44, 64, 36, + nil, 36, nil, nil, nil, nil, 44, nil, nil, nil, nil, nil, nil, nil, nil, 45, nil, 36, nil, nil, 44, 36, nil, nil, nil, nil, nil, 44, nil, nil, 45, nil, nil, nil, nil, nil, nil, nil, 45, nil, @@ -890,18 +890,18 @@ def raise_parse_error(error_message, location) 44, 45, 44, 45 ] racc_goto_pointer = [ - nil, 13, 14, 14, 8, -21, 21, 23, -61, 30, - 9, 36, 37, 58, 48, 15, 38, -39, -85, 11, - -57, nil, -119, 16, -55, 18, -53, 20, -47, 26, - -46, 59, 59, 2, -25, -66, -10, -22, 21, -110, - -138, -152, 5, -86, -33, -43, -165, -178, -88, -123, - -16, -32, -3, -50, 49, -25, -68, -73, 12, nil, - -21, -117, -61, -107, 18, -171 ] + nil, 13, 19, 21, 20, -11, 32, 34, -50, 53, + 8, 54, 46, 12, 1, -42, -89, 7, -63, nil, + nil, nil, -122, 10, -58, 15, -56, 17, -54, 19, + -48, 57, 57, 2, -25, -66, -10, -24, 19, -110, + -138, -152, 3, -88, -33, -43, -163, -178, -90, -125, + -18, -32, -5, -53, 45, -28, -69, -73, 12, nil, + -23, -117, -64, -111, 14, -171 ] racc_goto_default = [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 44, nil, nil, nil, nil, nil, nil, nil, nil, - nil, 23, nil, nil, nil, nil, nil, nil, nil, nil, + nil, 44, nil, nil, nil, nil, nil, nil, nil, 21, + 22, 23, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 72, 78, nil, nil, nil, nil, nil, 45, 163, 201, nil, nil, nil, nil, nil, 79, nil, nil, nil, nil, nil, 82, 84, nil, 43, @@ -921,23 +921,23 @@ def raise_parse_error(error_message, location) 0, 57, :_reduce_10, 3, 57, :_reduce_none, 1, 63, :_reduce_none, - 1, 63, :_reduce_none, - 1, 63, :_reduce_none, - 2, 63, :_reduce_15, + 2, 63, :_reduce_13, 3, 63, :_reduce_none, 2, 63, :_reduce_none, - 2, 63, :_reduce_18, - 2, 63, :_reduce_19, - 0, 71, :_reduce_20, - 0, 72, :_reduce_21, - 7, 63, :_reduce_22, - 0, 73, :_reduce_23, - 0, 74, :_reduce_24, - 6, 63, :_reduce_25, - 1, 63, :_reduce_26, - 0, 77, :_reduce_27, - 0, 78, :_reduce_28, - 6, 65, :_reduce_29, + 2, 63, :_reduce_16, + 2, 63, :_reduce_17, + 0, 69, :_reduce_18, + 0, 70, :_reduce_19, + 7, 63, :_reduce_20, + 0, 71, :_reduce_21, + 0, 72, :_reduce_22, + 6, 63, :_reduce_23, + 1, 63, :_reduce_24, + 0, 77, :_reduce_25, + 0, 78, :_reduce_26, + 6, 65, :_reduce_27, + 1, 65, :_reduce_none, + 1, 65, :_reduce_none, 1, 65, :_reduce_none, 0, 79, :_reduce_31, 0, 80, :_reduce_32, @@ -953,12 +953,12 @@ def raise_parse_error(error_message, location) 2, 65, :_reduce_42, 2, 65, :_reduce_43, 2, 65, :_reduce_44, - 2, 75, :_reduce_none, - 2, 75, :_reduce_46, - 2, 75, :_reduce_47, - 2, 75, :_reduce_48, - 2, 75, :_reduce_49, - 2, 75, :_reduce_50, + 2, 73, :_reduce_none, + 2, 73, :_reduce_46, + 2, 73, :_reduce_47, + 2, 73, :_reduce_48, + 2, 73, :_reduce_49, + 2, 73, :_reduce_50, 1, 85, :_reduce_51, 2, 85, :_reduce_52, 3, 85, :_reduce_53, @@ -969,9 +969,9 @@ def raise_parse_error(error_message, location) 3, 89, :_reduce_58, 0, 95, :_reduce_none, 1, 95, :_reduce_none, - 8, 66, :_reduce_61, - 5, 67, :_reduce_62, - 8, 67, :_reduce_63, + 8, 74, :_reduce_61, + 5, 75, :_reduce_62, + 8, 75, :_reduce_63, 1, 93, :_reduce_64, 3, 93, :_reduce_65, 1, 94, :_reduce_66, @@ -996,10 +996,10 @@ def raise_parse_error(error_message, location) 1, 98, :_reduce_none, 0, 106, :_reduce_86, 0, 107, :_reduce_87, - 6, 70, :_reduce_88, + 6, 68, :_reduce_88, 0, 108, :_reduce_89, 0, 109, :_reduce_90, - 5, 70, :_reduce_91, + 5, 68, :_reduce_91, 1, 87, :_reduce_92, 2, 87, :_reduce_93, 3, 87, :_reduce_94, @@ -1037,11 +1037,11 @@ def raise_parse_error(error_message, location) 0, 59, :_reduce_none, 0, 118, :_reduce_127, 3, 59, :_reduce_128, - 1, 68, :_reduce_none, - 0, 69, :_reduce_none, - 1, 69, :_reduce_none, - 1, 69, :_reduce_none, - 1, 69, :_reduce_none, + 1, 66, :_reduce_none, + 0, 67, :_reduce_none, + 1, 67, :_reduce_none, + 1, 67, :_reduce_none, + 1, 67, :_reduce_none, 1, 76, :_reduce_134, 2, 76, :_reduce_135, 1, 119, :_reduce_none, @@ -1196,8 +1196,6 @@ def raise_parse_error(error_message, location) "bison_declaration", "\"-option@;\"", "grammar_declaration", - "rule_declaration", - "inline_declaration", "variable", "value", "params", @@ -1206,6 +1204,8 @@ def raise_parse_error(error_message, location) "@5", "@6", "symbol_declaration", + "rule_declaration", + "inline_declaration", "generic_symlist", "@7", "@8", @@ -1306,23 +1306,19 @@ def _reduce_10(val, _values, result) # reduce 12 omitted -# reduce 13 omitted - -# reduce 14 omitted - -module_eval(<<'.,.,', 'parser.y', 34) - def _reduce_15(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 32) + def _reduce_13(val, _values, result) @grammar.expect = val[1] result end .,., -# reduce 16 omitted +# reduce 14 omitted -# reduce 17 omitted +# reduce 15 omitted -module_eval(<<'.,.,', 'parser.y', 39) - def _reduce_18(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 37) + def _reduce_16(val, _values, result) val[1].each {|token| @grammar.lex_param = Grammar::Code::NoReferenceCode.new(type: :lex_param, token_code: token).token_code.s_value } @@ -1331,8 +1327,8 @@ def _reduce_18(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 45) - def _reduce_19(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 43) + def _reduce_17(val, _values, result) val[1].each {|token| @grammar.parse_param = Grammar::Code::NoReferenceCode.new(type: :parse_param, token_code: token).token_code.s_value } @@ -1341,79 +1337,79 @@ def _reduce_19(val, _values, result) end .,., -module_eval(<<'.,.,', 'parser.y', 51) - def _reduce_20(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 49) + def _reduce_18(val, _values, result) begin_c_declaration("}") result end .,., -module_eval(<<'.,.,', 'parser.y', 55) - def _reduce_21(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 53) + def _reduce_19(val, _values, result) end_c_declaration result end .,., -module_eval(<<'.,.,', 'parser.y', 59) - def _reduce_22(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 57) + def _reduce_20(val, _values, result) @grammar.add_percent_code(id: val[1], code: val[4]) result end .,., -module_eval(<<'.,.,', 'parser.y', 63) - def _reduce_23(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 61) + def _reduce_21(val, _values, result) begin_c_declaration("}") result end .,., -module_eval(<<'.,.,', 'parser.y', 67) - def _reduce_24(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 65) + def _reduce_22(val, _values, result) end_c_declaration result end .,., -module_eval(<<'.,.,', 'parser.y', 71) - def _reduce_25(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 69) + def _reduce_23(val, _values, result) @grammar.initial_action = Grammar::Code::InitialActionCode.new(type: :initial_action, token_code: val[3]) result end .,., -module_eval(<<'.,.,', 'parser.y', 73) - def _reduce_26(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 71) + def _reduce_24(val, _values, result) @grammar.no_stdlib = true result end .,., -module_eval(<<'.,.,', 'parser.y', 77) - def _reduce_27(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 75) + def _reduce_25(val, _values, result) begin_c_declaration("}") result end .,., -module_eval(<<'.,.,', 'parser.y', 81) - def _reduce_28(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 79) + def _reduce_26(val, _values, result) end_c_declaration result end .,., -module_eval(<<'.,.,', 'parser.y', 85) - def _reduce_29(val, _values, result) +module_eval(<<'.,.,', 'parser.y', 83) + def _reduce_27(val, _values, result) @grammar.set_union( Grammar::Code::NoReferenceCode.new(type: :union, token_code: val[3]), val[3].line @@ -1423,6 +1419,10 @@ def _reduce_29(val, _values, result) end .,., +# reduce 28 omitted + +# reduce 29 omitted + # reduce 30 omitted module_eval(<<'.,.,', 'parser.y', 93) diff --git a/parser.y b/parser.y index 8b7b0e46..987390bc 100644 --- a/parser.y +++ b/parser.y @@ -30,8 +30,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 3e8ff6a6..8b14ee5f 100644 --- a/spec/lrama/parser_spec.rb +++ b/spec/lrama/parser_spec.rb @@ -1430,6 +1430,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([ @@ -1478,6 +1479,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 @@ -2324,8 +2359,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([ @@ -2404,6 +2439,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