lrama 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/NEWS.md +40 -0
- data/lib/lrama/grammar/rule_builder.rb +2 -1
- data/lib/lrama/lexer/token/user_code.rb +2 -0
- data/lib/lrama/parser.rb +66 -67
- data/lib/lrama/version.rb +1 -1
- data/parser.y +2 -1
- data/sig/lrama/lexer/token/user_code.rbs +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0278f10f4ec931a33647698e0b504d6f7051049b4f13429b804b30911019787e'
|
4
|
+
data.tar.gz: 51b687fabf61ac011848b17c34a151409e9bcd4cf14382ec5f9db365cb480d13
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf16ab8c270f7b694798ffaa1ea6e30e09c0e7b5139866fee44e4b7e0ee1b54148c2c237b3155f31b5a599c7cd141505190de3089ae4f2521a6d0de2901a9a92
|
7
|
+
data.tar.gz: 84cca8a68fb47d48e11782c11675a7d43f18a4dec1d4472ccf764e6995e7e79ecd54b437428ba15e177d36fd9e9be76b71f0aa59fd63976f13594b68a69a353b
|
data/NEWS.md
CHANGED
@@ -1,5 +1,45 @@
|
|
1
1
|
# NEWS for Lrama
|
2
2
|
|
3
|
+
## Lrama 0.6.5 (2024-03-25)
|
4
|
+
|
5
|
+
### Typed Midrule Actions
|
6
|
+
|
7
|
+
User can specify the type of mid rule action by tag (`<bar>`) instead of specifying it with in an action.
|
8
|
+
|
9
|
+
```
|
10
|
+
primary: k_case expr_value terms?
|
11
|
+
{
|
12
|
+
$<val>$ = p->case_labels;
|
13
|
+
p->case_labels = Qnil;
|
14
|
+
}
|
15
|
+
case_body
|
16
|
+
k_end
|
17
|
+
{
|
18
|
+
...
|
19
|
+
}
|
20
|
+
```
|
21
|
+
|
22
|
+
can be written as
|
23
|
+
|
24
|
+
```
|
25
|
+
primary: k_case expr_value terms?
|
26
|
+
{
|
27
|
+
$$ = p->case_labels;
|
28
|
+
p->case_labels = Qnil;
|
29
|
+
}<val>
|
30
|
+
case_body
|
31
|
+
k_end
|
32
|
+
{
|
33
|
+
...
|
34
|
+
}
|
35
|
+
```
|
36
|
+
|
37
|
+
`%destructor` for midrule action is invoked only when tag is specified by Typed Midrule Actions.
|
38
|
+
|
39
|
+
Difference from Bison's Typed Midrule Actions is that tag is postposed in Lrama however it's preposed in Bison.
|
40
|
+
|
41
|
+
Bison supports this feature from 3.1.
|
42
|
+
|
3
43
|
## Lrama 0.6.4 (2024-03-22)
|
4
44
|
|
5
45
|
### Parameterizing rules (preceded, terminated, delimited)
|
@@ -128,10 +128,11 @@ module Lrama
|
|
128
128
|
end
|
129
129
|
when Lrama::Lexer::Token::UserCode
|
130
130
|
prefix = token.referred ? "@" : "$@"
|
131
|
+
tag = token.tag || lhs_tag
|
131
132
|
new_token = Lrama::Lexer::Token::Ident.new(s_value: prefix + @midrule_action_counter.increment.to_s)
|
132
133
|
@replaced_rhs << new_token
|
133
134
|
|
134
|
-
rule_builder = RuleBuilder.new(@rule_counter, @midrule_action_counter, i, lhs_tag:
|
135
|
+
rule_builder = RuleBuilder.new(@rule_counter, @midrule_action_counter, i, lhs_tag: tag, skip_preprocess_references: true)
|
135
136
|
rule_builder.lhs = new_token
|
136
137
|
rule_builder.user_code = token
|
137
138
|
rule_builder.complete_input
|
data/lib/lrama/parser.rb
CHANGED
@@ -658,7 +658,7 @@ end
|
|
658
658
|
module Lrama
|
659
659
|
class Parser < Racc::Parser
|
660
660
|
|
661
|
-
module_eval(<<'...end parser.y/module_eval...', 'parser.y',
|
661
|
+
module_eval(<<'...end parser.y/module_eval...', 'parser.y', 529)
|
662
662
|
|
663
663
|
include Lrama::Report::Duration
|
664
664
|
|
@@ -759,7 +759,7 @@ racc_action_table = [
|
|
759
759
|
126, 127, 128, 129, 130, 133, 137, 138, 139, 142,
|
760
760
|
143, 144, 146, 161, 163, 164, 165, 166, 167, 168,
|
761
761
|
169, 142, 171, 179, 180, 189, 194, 195, 197, 202,
|
762
|
-
189, 94, 194, 216, 218, 94,
|
762
|
+
189, 94, 194, 216, 218, 94, 194, 224, 94 ]
|
763
763
|
|
764
764
|
racc_action_check = [
|
765
765
|
48, 141, 48, 141, 140, 141, 170, 188, 170, 188,
|
@@ -789,7 +789,7 @@ racc_action_check = [
|
|
789
789
|
102, 103, 104, 105, 106, 110, 118, 119, 120, 121,
|
790
790
|
122, 123, 125, 145, 147, 148, 149, 150, 151, 152,
|
791
791
|
153, 154, 156, 160, 162, 168, 173, 177, 187, 190,
|
792
|
-
197, 198, 203, 206, 211, 216, 222,
|
792
|
+
197, 198, 203, 206, 211, 216, 220, 222, 224 ]
|
793
793
|
|
794
794
|
racc_action_pointer = [
|
795
795
|
nil, 20, 9, 26, 97, nil, nil, 23, nil, 32,
|
@@ -814,10 +814,10 @@ racc_action_pointer = [
|
|
814
814
|
229, 166, 163, nil, nil, nil, nil, 225, 221, -16,
|
815
815
|
nil, 183, 188, 264, 189, nil, 253, 9, nil, nil,
|
816
816
|
194, 272, nil, 172, nil, nil, 225, 173, nil, nil,
|
817
|
-
|
817
|
+
268, nil, 257, nil, 228, nil ]
|
818
818
|
|
819
819
|
racc_action_default = [
|
820
|
-
-2, -136, -8, -136, -136, -3, -4, -136,
|
820
|
+
-2, -136, -8, -136, -136, -3, -4, -136, 226, -136,
|
821
821
|
-9, -10, -11, -136, -136, -136, -136, -136, -136, -136,
|
822
822
|
-23, -24, -136, -28, -136, -136, -136, -136, -136, -136,
|
823
823
|
-136, -136, -136, -136, -136, -136, -136, -136, -136, -136,
|
@@ -839,58 +839,56 @@ racc_action_default = [
|
|
839
839
|
-92, -136, -114, -105, -135, -108, -130, -60, -118, -92,
|
840
840
|
-65, -136, -136, -134, -136, -116, -136, -59, -62, -63,
|
841
841
|
-136, -136, -68, -136, -106, -115, -118, -136, -66, -117,
|
842
|
-
-
|
842
|
+
-134, -64, -136, -109, -118, -67 ]
|
843
843
|
|
844
844
|
racc_goto_table = [
|
845
|
-
93,
|
846
|
-
|
847
|
-
|
848
|
-
52, 54, 55, 181, 185, 186,
|
849
|
-
109, 116, 205, 114,
|
850
|
-
|
851
|
-
12, 48, 95, 125, 162, 102, 147, 83, 83,
|
852
|
-
103, 148, 104, 149, 105, 150, 106,
|
853
|
-
|
854
|
-
123, 160, 100, 145, 71, 140, 71, 177, 206,
|
855
|
-
|
856
|
-
nil, nil, 172,
|
857
|
-
nil, nil, 83, nil, nil, nil,
|
858
|
-
nil,
|
859
|
-
nil, nil,
|
860
|
-
nil, nil, nil, 208, nil, nil,
|
861
|
-
|
862
|
-
|
863
|
-
nil, nil, 192 ]
|
845
|
+
93, 75, 51, 68, 73, 193, 116, 108, 191, 173,
|
846
|
+
196, 1, 117, 2, 196, 196, 141, 4, 42, 41,
|
847
|
+
71, 89, 83, 83, 83, 83, 188, 79, 84, 85,
|
848
|
+
86, 52, 54, 55, 5, 214, 181, 185, 186, 213,
|
849
|
+
109, 113, 75, 116, 205, 114, 135, 217, 108, 170,
|
850
|
+
90, 209, 223, 39, 119, 207, 71, 71, 10, 11,
|
851
|
+
12, 116, 48, 95, 125, 162, 102, 147, 83, 83,
|
852
|
+
108, 103, 148, 104, 149, 105, 150, 106, 131, 151,
|
853
|
+
75, 67, 113, 134, 72, 110, 132, 136, 187, 211,
|
854
|
+
222, 123, 160, 100, 145, 71, 140, 71, 177, 206,
|
855
|
+
120, nil, 113, 83, nil, 83, nil, nil, nil, 157,
|
856
|
+
nil, nil, 172, nil, nil, nil, nil, nil, nil, 71,
|
857
|
+
nil, nil, nil, 83, nil, nil, nil, 178, nil, nil,
|
858
|
+
nil, nil, nil, nil, nil, nil, nil, nil, 157, 192,
|
859
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
860
|
+
nil, nil, nil, 208, nil, nil, 198, nil, nil, nil,
|
861
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 212,
|
862
|
+
192, 220, 215, nil, nil, 198, nil, nil, 192, 225 ]
|
864
863
|
|
865
864
|
racc_goto_check = [
|
866
|
-
41, 34, 46,
|
867
|
-
|
868
|
-
|
869
|
-
14, 14, 14,
|
870
|
-
32, 53, 42, 46,
|
871
|
-
|
872
|
-
11, 12, 13, 15, 16, 17, 18, 34, 34,
|
873
|
-
21, 22, 23, 24, 25, 26, 27,
|
874
|
-
|
875
|
-
48, 49, 50, 51, 34, 57, 34, 60, 61,
|
876
|
-
|
877
|
-
nil, nil, 41,
|
878
|
-
nil, nil, 34, nil, nil, nil,
|
879
|
-
nil,
|
880
|
-
nil, nil,
|
881
|
-
nil, nil, nil, 41, nil, nil,
|
882
|
-
|
883
|
-
|
884
|
-
nil, nil, 40 ]
|
865
|
+
41, 40, 34, 32, 46, 59, 53, 33, 43, 42,
|
866
|
+
63, 1, 52, 2, 63, 63, 58, 3, 54, 4,
|
867
|
+
34, 5, 34, 34, 34, 34, 39, 31, 31, 31,
|
868
|
+
31, 14, 14, 14, 6, 59, 20, 20, 20, 43,
|
869
|
+
32, 40, 40, 53, 42, 46, 52, 43, 33, 58,
|
870
|
+
54, 42, 59, 7, 8, 39, 34, 34, 9, 10,
|
871
|
+
11, 53, 12, 13, 15, 16, 17, 18, 34, 34,
|
872
|
+
33, 21, 22, 23, 24, 25, 26, 27, 32, 28,
|
873
|
+
40, 29, 40, 46, 30, 35, 36, 37, 38, 44,
|
874
|
+
45, 48, 49, 50, 51, 34, 57, 34, 60, 61,
|
875
|
+
62, nil, 40, 34, nil, 34, nil, nil, nil, 40,
|
876
|
+
nil, nil, 41, nil, nil, nil, nil, nil, nil, 34,
|
877
|
+
nil, nil, nil, 34, nil, nil, nil, 40, nil, nil,
|
878
|
+
nil, nil, nil, nil, nil, nil, nil, nil, 40, 40,
|
879
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
880
|
+
nil, nil, nil, 41, nil, nil, 40, nil, nil, nil,
|
881
|
+
nil, nil, nil, nil, nil, nil, nil, nil, nil, 40,
|
882
|
+
40, 41, 40, nil, nil, 40, nil, nil, 40, 41 ]
|
885
883
|
|
886
884
|
racc_goto_pointer = [
|
887
|
-
nil,
|
888
|
-
|
889
|
-
-
|
890
|
-
|
891
|
-
-
|
892
|
-
|
893
|
-
-
|
885
|
+
nil, 11, 13, 15, 10, -20, 32, 47, -34, 54,
|
886
|
+
55, 56, 48, 15, 16, -37, -81, 9, -59, nil,
|
887
|
+
-129, 13, -55, 14, -54, 15, -53, 16, -51, 49,
|
888
|
+
51, -7, -29, -61, -12, 14, -24, -31, -80, -142,
|
889
|
+
-32, -45, -148, -163, -111, -128, -29, nil, -8, -52,
|
890
|
+
40, -30, -69, -74, 9, nil, nil, -25, -105, -168,
|
891
|
+
-60, -96, 9, -171 ]
|
894
892
|
|
895
893
|
racc_goto_default = [
|
896
894
|
nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
@@ -1011,7 +1009,7 @@ racc_reduce_table = [
|
|
1011
1009
|
6, 111, :_reduce_106,
|
1012
1010
|
0, 113, :_reduce_107,
|
1013
1011
|
0, 114, :_reduce_108,
|
1014
|
-
|
1012
|
+
8, 111, :_reduce_109,
|
1015
1013
|
3, 111, :_reduce_110,
|
1016
1014
|
1, 95, :_reduce_111,
|
1017
1015
|
1, 95, :_reduce_112,
|
@@ -1041,7 +1039,7 @@ racc_reduce_table = [
|
|
1041
1039
|
|
1042
1040
|
racc_reduce_n = 136
|
1043
1041
|
|
1044
|
-
racc_shift_n =
|
1042
|
+
racc_shift_n = 226
|
1045
1043
|
|
1046
1044
|
racc_token_table = {
|
1047
1045
|
false => 0,
|
@@ -2066,6 +2064,7 @@ module_eval(<<'.,.,', 'parser.y', 466)
|
|
2066
2064
|
def _reduce_109(val, _values, result)
|
2067
2065
|
user_code = val[3]
|
2068
2066
|
user_code.alias_name = val[6]
|
2067
|
+
user_code.tag = val[7]
|
2069
2068
|
builder = val[0]
|
2070
2069
|
builder.user_code = user_code
|
2071
2070
|
result = builder
|
@@ -2074,7 +2073,7 @@ module_eval(<<'.,.,', 'parser.y', 466)
|
|
2074
2073
|
end
|
2075
2074
|
.,.,
|
2076
2075
|
|
2077
|
-
module_eval(<<'.,.,', 'parser.y',
|
2076
|
+
module_eval(<<'.,.,', 'parser.y', 475)
|
2078
2077
|
def _reduce_110(val, _values, result)
|
2079
2078
|
sym = @grammar.find_symbol_by_id!(val[2])
|
2080
2079
|
@prec_seen = true
|
@@ -2086,49 +2085,49 @@ module_eval(<<'.,.,', 'parser.y', 474)
|
|
2086
2085
|
end
|
2087
2086
|
.,.,
|
2088
2087
|
|
2089
|
-
module_eval(<<'.,.,', 'parser.y',
|
2088
|
+
module_eval(<<'.,.,', 'parser.y', 482)
|
2090
2089
|
def _reduce_111(val, _values, result)
|
2091
2090
|
result = "option"
|
2092
2091
|
result
|
2093
2092
|
end
|
2094
2093
|
.,.,
|
2095
2094
|
|
2096
|
-
module_eval(<<'.,.,', 'parser.y',
|
2095
|
+
module_eval(<<'.,.,', 'parser.y', 483)
|
2097
2096
|
def _reduce_112(val, _values, result)
|
2098
2097
|
result = "nonempty_list"
|
2099
2098
|
result
|
2100
2099
|
end
|
2101
2100
|
.,.,
|
2102
2101
|
|
2103
|
-
module_eval(<<'.,.,', 'parser.y',
|
2102
|
+
module_eval(<<'.,.,', 'parser.y', 484)
|
2104
2103
|
def _reduce_113(val, _values, result)
|
2105
2104
|
result = "list"
|
2106
2105
|
result
|
2107
2106
|
end
|
2108
2107
|
.,.,
|
2109
2108
|
|
2110
|
-
module_eval(<<'.,.,', 'parser.y',
|
2109
|
+
module_eval(<<'.,.,', 'parser.y', 486)
|
2111
2110
|
def _reduce_114(val, _values, result)
|
2112
2111
|
result = [val[0]]
|
2113
2112
|
result
|
2114
2113
|
end
|
2115
2114
|
.,.,
|
2116
2115
|
|
2117
|
-
module_eval(<<'.,.,', 'parser.y',
|
2116
|
+
module_eval(<<'.,.,', 'parser.y', 487)
|
2118
2117
|
def _reduce_115(val, _values, result)
|
2119
2118
|
result = val[0].append(val[2])
|
2120
2119
|
result
|
2121
2120
|
end
|
2122
2121
|
.,.,
|
2123
2122
|
|
2124
|
-
module_eval(<<'.,.,', 'parser.y',
|
2123
|
+
module_eval(<<'.,.,', 'parser.y', 488)
|
2125
2124
|
def _reduce_116(val, _values, result)
|
2126
2125
|
result = [Lrama::Lexer::Token::InstantiateRule.new(s_value: val[1].s_value, location: @lexer.location, args: val[0])]
|
2127
2126
|
result
|
2128
2127
|
end
|
2129
2128
|
.,.,
|
2130
2129
|
|
2131
|
-
module_eval(<<'.,.,', 'parser.y',
|
2130
|
+
module_eval(<<'.,.,', 'parser.y', 489)
|
2132
2131
|
def _reduce_117(val, _values, result)
|
2133
2132
|
result = [Lrama::Lexer::Token::InstantiateRule.new(s_value: val[0].s_value, location: @lexer.location, args: val[2])]
|
2134
2133
|
result
|
@@ -2137,7 +2136,7 @@ module_eval(<<'.,.,', 'parser.y', 488)
|
|
2137
2136
|
|
2138
2137
|
# reduce 118 omitted
|
2139
2138
|
|
2140
|
-
module_eval(<<'.,.,', 'parser.y',
|
2139
|
+
module_eval(<<'.,.,', 'parser.y', 492)
|
2141
2140
|
def _reduce_119(val, _values, result)
|
2142
2141
|
result = val[1].s_value
|
2143
2142
|
result
|
@@ -2148,7 +2147,7 @@ module_eval(<<'.,.,', 'parser.y', 491)
|
|
2148
2147
|
|
2149
2148
|
# reduce 121 omitted
|
2150
2149
|
|
2151
|
-
module_eval(<<'.,.,', 'parser.y',
|
2150
|
+
module_eval(<<'.,.,', 'parser.y', 499)
|
2152
2151
|
def _reduce_122(val, _values, result)
|
2153
2152
|
begin_c_declaration('\Z')
|
2154
2153
|
@grammar.epilogue_first_lineno = @lexer.line + 1
|
@@ -2157,7 +2156,7 @@ module_eval(<<'.,.,', 'parser.y', 498)
|
|
2157
2156
|
end
|
2158
2157
|
.,.,
|
2159
2158
|
|
2160
|
-
module_eval(<<'.,.,', 'parser.y',
|
2159
|
+
module_eval(<<'.,.,', 'parser.y', 504)
|
2161
2160
|
def _reduce_123(val, _values, result)
|
2162
2161
|
end_c_declaration
|
2163
2162
|
@grammar.epilogue = val[2].s_value
|
@@ -2176,14 +2175,14 @@ module_eval(<<'.,.,', 'parser.y', 503)
|
|
2176
2175
|
|
2177
2176
|
# reduce 128 omitted
|
2178
2177
|
|
2179
|
-
module_eval(<<'.,.,', 'parser.y',
|
2178
|
+
module_eval(<<'.,.,', 'parser.y', 515)
|
2180
2179
|
def _reduce_129(val, _values, result)
|
2181
2180
|
result = [val[0]]
|
2182
2181
|
result
|
2183
2182
|
end
|
2184
2183
|
.,.,
|
2185
2184
|
|
2186
|
-
module_eval(<<'.,.,', 'parser.y',
|
2185
|
+
module_eval(<<'.,.,', 'parser.y', 516)
|
2187
2186
|
def _reduce_130(val, _values, result)
|
2188
2187
|
result = val[0].append(val[1])
|
2189
2188
|
result
|
@@ -2194,7 +2193,7 @@ module_eval(<<'.,.,', 'parser.y', 515)
|
|
2194
2193
|
|
2195
2194
|
# reduce 132 omitted
|
2196
2195
|
|
2197
|
-
module_eval(<<'.,.,', 'parser.y',
|
2196
|
+
module_eval(<<'.,.,', 'parser.y', 521)
|
2198
2197
|
def _reduce_133(val, _values, result)
|
2199
2198
|
result = Lrama::Lexer::Token::Ident.new(s_value: val[0])
|
2200
2199
|
result
|
data/lib/lrama/version.rb
CHANGED
data/parser.y
CHANGED
@@ -462,10 +462,11 @@ rule
|
|
462
462
|
{
|
463
463
|
end_c_declaration
|
464
464
|
}
|
465
|
-
"}" named_ref_opt
|
465
|
+
"}" named_ref_opt tag_opt
|
466
466
|
{
|
467
467
|
user_code = val[3]
|
468
468
|
user_code.alias_name = val[6]
|
469
|
+
user_code.tag = val[7]
|
469
470
|
builder = val[0]
|
470
471
|
builder.user_code = user_code
|
471
472
|
result = builder
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lrama
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuichiro Kaneko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-03-
|
11
|
+
date: 2024-03-24 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: LALR (1) parser generator written by Ruby
|
14
14
|
email:
|