depager 0.2.0 → 0.2.2
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.
- data/ChangeLog +4 -0
- data/README.en +5 -10
- data/bin/depager +17 -20
- data/examples/c89/c89.tab.rb +5632 -702
- data/examples/pl0d/pl0ds.dr +41 -41
- data/examples/pl0d/pl0ds.tab.rb +1887 -874
- data/examples/sample_calc/calc.action.tab.rb +243 -69
- data/examples/sample_calc/{calc.astl.action.dr → calc.ast.action.dr} +7 -7
- data/examples/sample_calc/calc.ast.action.tab.rb +755 -0
- data/examples/sample_calc/{calc.astl.dr → calc.ast.dr} +7 -7
- data/examples/sample_calc/calc.ast.tab.rb +672 -0
- data/examples/sample_calc/calc.astdf.dr +5 -5
- data/examples/sample_calc/calc.astdf.tab.rb +405 -202
- data/examples/sample_calc/calc.atree.tab.rb +243 -69
- data/examples/sample_calc/calc.cst.tab.rb +275 -109
- data/examples/sample_calc/calc.lex.tab.rb +210 -28
- data/examples/sample_calc/calc.nvaction.tab.rb +251 -77
- data/examples/sample_calc/calc.tab.rb +210 -28
- data/examples/sample_calc/calc_prec.nvaction.tab.rb +224 -50
- data/examples/slex_test/divreg.slex.tab.rb +97 -21
- data/examples/slex_test/ljoin.slex.tab.rb +128 -35
- data/lib/depager.rb +77 -44
- data/lib/depager/{ast_base.dr → ast.dr} +56 -18
- data/lib/depager/{ast_base.rb → ast.rb} +432 -424
- data/lib/depager/astdf.rb +3 -6
- data/lib/depager/atree.rb +54 -62
- data/lib/depager/cst.dr +2 -2
- data/lib/depager/cst.rb +64 -77
- data/lib/depager/grammar.rb +225 -66
- data/lib/depager/lex.dr +1 -1
- data/lib/depager/lex.rb +45 -54
- data/lib/depager/lr.rb +181 -262
- data/lib/depager/lr_put_table.rb +116 -0
- data/lib/depager/nvaction.rb +1 -1
- data/lib/depager/parser.rb +23 -2
- data/lib/depager/slex.dr +3 -3
- data/lib/depager/slex.rb +148 -169
- data/lib/depager/srp.rb +1 -1
- data/lib/depager/template/ast.erbs +69 -0
- data/lib/depager/template/extension_lalr_master.erb +3 -3
- data/lib/depager/template/extension_lalr_slave.erb +7 -7
- data/lib/depager/template/simple.erb +4 -2
- data/lib/depager/template/single_lalr_parser.erb +30 -10
- data/lib/depager/utils.rb +10 -9
- data/lib/depager/version.rb +2 -8
- metadata +10 -11
- data/examples/sample_calc/calc.astl.action.tab.rb +0 -593
- data/examples/sample_calc/calc.astl.tab.rb +0 -501
- data/lib/depager/astl.rb +0 -14
- data/lib/depager/template/astdf.erbs +0 -57
- data/lib/depager/template/astl.erbs +0 -57
@@ -3,8 +3,8 @@ begin; require 'rubygems'; rescue Exception; end
|
|
3
3
|
require 'depager/parser.rb'
|
4
4
|
|
5
5
|
|
6
|
-
module
|
7
|
-
end
|
6
|
+
module Depager::DecoratorUtils; end
|
7
|
+
module D4TinyCalc; end
|
8
8
|
|
9
9
|
class TinyCalc < Depager::LALR::Basis
|
10
10
|
|
@@ -12,14 +12,14 @@ class TinyCalc < Depager::LALR::Basis
|
|
12
12
|
### Reduce Table
|
13
13
|
reduce_table = [
|
14
14
|
[ -1, 1 ], # ( 0) $start : expr
|
15
|
-
[ 0, 3 ], # ( 1) expr : expr + term
|
16
|
-
[ 0, 3 ], # ( 2) expr : expr - term
|
15
|
+
[ 0, 3 ], # ( 1) expr : expr '+' term
|
16
|
+
[ 0, 3 ], # ( 2) expr : expr '-' term
|
17
17
|
[ 0, 1 ], # ( 3) expr : term
|
18
|
-
[ 1, 3 ], # ( 4) term : term * fact
|
19
|
-
[ 1, 3 ], # ( 5) term : term / fact
|
18
|
+
[ 1, 3 ], # ( 4) term : term '*' fact
|
19
|
+
[ 1, 3 ], # ( 5) term : term '/' fact
|
20
20
|
[ 1, 1 ], # ( 6) term : fact
|
21
21
|
[ 2, 1 ], # ( 7) fact : NUM
|
22
|
-
[ 2, 3 ], # ( 8) fact : ( expr )
|
22
|
+
[ 2, 3 ], # ( 8) fact : '(' expr ')'
|
23
23
|
]
|
24
24
|
### Extension Params
|
25
25
|
nparams = {
|
@@ -50,26 +50,25 @@ class TinyCalc < Depager::LALR::Basis
|
|
50
50
|
]
|
51
51
|
### Action Table
|
52
52
|
action_table = [
|
53
|
-
[ nil, nil, nil, nil, nil, nil,
|
54
|
-
[
|
55
|
-
[
|
56
|
-
[ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
|
53
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
54
|
+
[ ACC, nil, 6, 7, nil, nil, nil, nil, nil, ],
|
55
|
+
[ nil, nil, nil, nil, 8, 9, nil, nil, nil, ],
|
57
56
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
58
57
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
59
|
-
[ nil, nil,
|
60
|
-
[ nil, nil, nil, nil, nil, nil,
|
61
|
-
[ nil, nil, nil, nil, nil, nil,
|
62
|
-
[ nil, nil, nil, nil, nil, nil,
|
63
|
-
[ nil, nil, nil, nil, nil, nil,
|
58
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
59
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
60
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
61
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
62
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
63
|
+
[ nil, nil, 6, 7, nil, nil, nil, nil, 15, ],
|
64
|
+
[ nil, nil, nil, nil, 8, 9, nil, nil, nil, ],
|
65
|
+
[ nil, nil, nil, nil, 8, 9, nil, nil, nil, ],
|
64
66
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
65
|
-
[ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
|
66
|
-
[ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
|
67
67
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
68
68
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
69
69
|
]
|
70
70
|
### Default Reduce Table
|
71
71
|
defred_table = [
|
72
|
-
nil,
|
73
72
|
nil,
|
74
73
|
nil,
|
75
74
|
-3,
|
@@ -80,17 +79,17 @@ class TinyCalc < Depager::LALR::Basis
|
|
80
79
|
nil,
|
81
80
|
nil,
|
82
81
|
nil,
|
83
|
-
|
82
|
+
nil,
|
84
83
|
-1,
|
85
84
|
-2,
|
86
85
|
-4,
|
87
86
|
-5,
|
87
|
+
-8,
|
88
88
|
]
|
89
89
|
defred_after_shift_table = [
|
90
90
|
nil,
|
91
91
|
nil,
|
92
92
|
nil,
|
93
|
-
nil,
|
94
93
|
-6,
|
95
94
|
-7,
|
96
95
|
nil,
|
@@ -98,11 +97,12 @@ class TinyCalc < Depager::LALR::Basis
|
|
98
97
|
nil,
|
99
98
|
nil,
|
100
99
|
nil,
|
101
|
-
|
100
|
+
nil,
|
102
101
|
nil,
|
103
102
|
nil,
|
104
103
|
-4,
|
105
104
|
-5,
|
105
|
+
-8,
|
106
106
|
]
|
107
107
|
### Nonterm to Int
|
108
108
|
nt2i = {
|
@@ -118,17 +118,17 @@ class TinyCalc < Depager::LALR::Basis
|
|
118
118
|
]
|
119
119
|
### Goto Table
|
120
120
|
goto_table = [
|
121
|
-
[ 2, 3,
|
122
|
-
[ 6, 3, 4, ],
|
121
|
+
[ 1, 2, 3, ],
|
123
122
|
[ nil, nil, nil, ],
|
124
123
|
[ nil, nil, nil, ],
|
125
124
|
[ nil, nil, nil, ],
|
126
125
|
[ nil, nil, nil, ],
|
127
|
-
[
|
128
|
-
[ nil,
|
129
|
-
[ nil,
|
126
|
+
[ 10, 2, 3, ],
|
127
|
+
[ nil, 11, 3, ],
|
128
|
+
[ nil, 12, 3, ],
|
129
|
+
[ nil, nil, 13, ],
|
130
130
|
[ nil, nil, 14, ],
|
131
|
-
[ nil, nil,
|
131
|
+
[ nil, nil, nil, ],
|
132
132
|
[ nil, nil, nil, ],
|
133
133
|
[ nil, nil, nil, ],
|
134
134
|
[ nil, nil, nil, ],
|
@@ -136,6 +136,188 @@ class TinyCalc < Depager::LALR::Basis
|
|
136
136
|
[ nil, nil, nil, ],
|
137
137
|
]
|
138
138
|
|
139
|
+
|
140
|
+
alias orig_error error
|
141
|
+
def error
|
142
|
+
orig_error
|
143
|
+
warn "current state: #{StateInfo[@stack.last]}"
|
144
|
+
end
|
145
|
+
|
146
|
+
### States
|
147
|
+
StateInfo = [
|
148
|
+
<<'----------',
|
149
|
+
I000 =
|
150
|
+
( 0) $start : _ expr
|
151
|
+
|
152
|
+
NUM shift, and goto to state 4
|
153
|
+
'(' shift, and goto to state 5
|
154
|
+
|
155
|
+
|
156
|
+
----------
|
157
|
+
|
158
|
+
<<'----------',
|
159
|
+
I001 =
|
160
|
+
( 0) $start : expr _
|
161
|
+
( 1) expr : expr _ '+' term
|
162
|
+
( 2) expr : expr _ '-' term
|
163
|
+
|
164
|
+
'+' shift, and goto to state 6
|
165
|
+
'-' shift, and goto to state 7
|
166
|
+
|
167
|
+
|
168
|
+
$end accept
|
169
|
+
|
170
|
+
----------
|
171
|
+
|
172
|
+
<<'----------',
|
173
|
+
I002 =
|
174
|
+
( 3) expr : term _
|
175
|
+
( 4) term : term _ '*' fact
|
176
|
+
( 5) term : term _ '/' fact
|
177
|
+
|
178
|
+
'*' shift, and goto to state 8
|
179
|
+
'/' shift, and goto to state 9
|
180
|
+
|
181
|
+
$default reduce using rule 3 (expr)
|
182
|
+
|
183
|
+
----------
|
184
|
+
|
185
|
+
<<'----------',
|
186
|
+
I003 =
|
187
|
+
( 6) term : fact _
|
188
|
+
|
189
|
+
|
190
|
+
$default reduce using rule 6 (term) [after shift]
|
191
|
+
|
192
|
+
----------
|
193
|
+
|
194
|
+
<<'----------',
|
195
|
+
I004 =
|
196
|
+
( 7) fact : NUM _
|
197
|
+
|
198
|
+
|
199
|
+
$default reduce using rule 7 (fact) [after shift]
|
200
|
+
|
201
|
+
----------
|
202
|
+
|
203
|
+
<<'----------',
|
204
|
+
I005 =
|
205
|
+
( 8) fact : '(' _ expr ')'
|
206
|
+
|
207
|
+
NUM shift, and goto to state 4
|
208
|
+
'(' shift, and goto to state 5
|
209
|
+
|
210
|
+
|
211
|
+
----------
|
212
|
+
|
213
|
+
<<'----------',
|
214
|
+
I006 =
|
215
|
+
( 1) expr : expr '+' _ term
|
216
|
+
|
217
|
+
NUM shift, and goto to state 4
|
218
|
+
'(' shift, and goto to state 5
|
219
|
+
|
220
|
+
|
221
|
+
----------
|
222
|
+
|
223
|
+
<<'----------',
|
224
|
+
I007 =
|
225
|
+
( 2) expr : expr '-' _ term
|
226
|
+
|
227
|
+
NUM shift, and goto to state 4
|
228
|
+
'(' shift, and goto to state 5
|
229
|
+
|
230
|
+
|
231
|
+
----------
|
232
|
+
|
233
|
+
<<'----------',
|
234
|
+
I008 =
|
235
|
+
( 4) term : term '*' _ fact
|
236
|
+
|
237
|
+
NUM shift, and goto to state 4
|
238
|
+
'(' shift, and goto to state 5
|
239
|
+
|
240
|
+
|
241
|
+
----------
|
242
|
+
|
243
|
+
<<'----------',
|
244
|
+
I009 =
|
245
|
+
( 5) term : term '/' _ fact
|
246
|
+
|
247
|
+
NUM shift, and goto to state 4
|
248
|
+
'(' shift, and goto to state 5
|
249
|
+
|
250
|
+
|
251
|
+
----------
|
252
|
+
|
253
|
+
<<'----------',
|
254
|
+
I010 =
|
255
|
+
( 8) fact : '(' expr _ ')'
|
256
|
+
( 1) expr : expr _ '+' term
|
257
|
+
( 2) expr : expr _ '-' term
|
258
|
+
|
259
|
+
'+' shift, and goto to state 6
|
260
|
+
'-' shift, and goto to state 7
|
261
|
+
')' shift, and goto to state 15
|
262
|
+
|
263
|
+
|
264
|
+
----------
|
265
|
+
|
266
|
+
<<'----------',
|
267
|
+
I011 =
|
268
|
+
( 1) expr : expr '+' term _
|
269
|
+
( 4) term : term _ '*' fact
|
270
|
+
( 5) term : term _ '/' fact
|
271
|
+
|
272
|
+
'*' shift, and goto to state 8
|
273
|
+
'/' shift, and goto to state 9
|
274
|
+
|
275
|
+
$default reduce using rule 1 (expr)
|
276
|
+
|
277
|
+
----------
|
278
|
+
|
279
|
+
<<'----------',
|
280
|
+
I012 =
|
281
|
+
( 2) expr : expr '-' term _
|
282
|
+
( 4) term : term _ '*' fact
|
283
|
+
( 5) term : term _ '/' fact
|
284
|
+
|
285
|
+
'*' shift, and goto to state 8
|
286
|
+
'/' shift, and goto to state 9
|
287
|
+
|
288
|
+
$default reduce using rule 2 (expr)
|
289
|
+
|
290
|
+
----------
|
291
|
+
|
292
|
+
<<'----------',
|
293
|
+
I013 =
|
294
|
+
( 4) term : term '*' fact _
|
295
|
+
|
296
|
+
|
297
|
+
$default reduce using rule 4 (term) [after shift]
|
298
|
+
|
299
|
+
----------
|
300
|
+
|
301
|
+
<<'----------',
|
302
|
+
I014 =
|
303
|
+
( 5) term : term '/' fact _
|
304
|
+
|
305
|
+
|
306
|
+
$default reduce using rule 5 (term) [after shift]
|
307
|
+
|
308
|
+
----------
|
309
|
+
|
310
|
+
<<'----------',
|
311
|
+
I015 =
|
312
|
+
( 8) fact : '(' expr ')' _
|
313
|
+
|
314
|
+
|
315
|
+
$default reduce using rule 8 (fact) [after shift]
|
316
|
+
|
317
|
+
----------
|
318
|
+
]
|
319
|
+
|
320
|
+
|
139
321
|
Tables = [ reduce_table, nparams, action_table,
|
140
322
|
defred_table, defred_after_shift_table, goto_table,
|
141
323
|
t2i, i2t, nt2i, i2nt ]
|
@@ -3,8 +3,8 @@ begin; require 'rubygems'; rescue Exception; end
|
|
3
3
|
require 'depager/parser.rb'
|
4
4
|
|
5
5
|
|
6
|
-
module
|
7
|
-
end
|
6
|
+
module Depager::DecoratorUtils; end
|
7
|
+
module D4TinyCalc; end
|
8
8
|
|
9
9
|
class TinyCalc < Depager::LALR::Basis
|
10
10
|
|
@@ -12,14 +12,14 @@ class TinyCalc < Depager::LALR::Basis
|
|
12
12
|
### Reduce Table
|
13
13
|
reduce_table = [
|
14
14
|
[ -1, 1 ], # ( 0) $start : expr
|
15
|
-
[ 0, 3 ], # ( 1) expr : expr + term
|
16
|
-
[ 0, 3 ], # ( 2) expr : expr - term
|
15
|
+
[ 0, 3 ], # ( 1) expr : expr '+' term
|
16
|
+
[ 0, 3 ], # ( 2) expr : expr '-' term
|
17
17
|
[ 0, 1 ], # ( 3) expr : term
|
18
|
-
[ 1, 3 ], # ( 4) term : term * fact
|
19
|
-
[ 1, 3 ], # ( 5) term : term / fact
|
18
|
+
[ 1, 3 ], # ( 4) term : term '*' fact
|
19
|
+
[ 1, 3 ], # ( 5) term : term '/' fact
|
20
20
|
[ 1, 1 ], # ( 6) term : fact
|
21
21
|
[ 2, 1 ], # ( 7) fact : NUM
|
22
|
-
[ 2, 3 ], # ( 8) fact : ( expr )
|
22
|
+
[ 2, 3 ], # ( 8) fact : '(' expr ')'
|
23
23
|
]
|
24
24
|
### Extension Params
|
25
25
|
nparams = {
|
@@ -51,26 +51,25 @@ class TinyCalc < Depager::LALR::Basis
|
|
51
51
|
]
|
52
52
|
### Action Table
|
53
53
|
action_table = [
|
54
|
-
[ nil, nil, nil, nil, nil, nil,
|
55
|
-
[
|
56
|
-
[
|
57
|
-
[ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
|
54
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
55
|
+
[ ACC, nil, 6, 7, nil, nil, nil, nil, nil, ],
|
56
|
+
[ nil, nil, nil, nil, 8, 9, nil, nil, nil, ],
|
58
57
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
59
58
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
60
|
-
[ nil, nil,
|
61
|
-
[ nil, nil, nil, nil, nil, nil,
|
62
|
-
[ nil, nil, nil, nil, nil, nil,
|
63
|
-
[ nil, nil, nil, nil, nil, nil,
|
64
|
-
[ nil, nil, nil, nil, nil, nil,
|
59
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
60
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
61
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
62
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
63
|
+
[ nil, nil, nil, nil, nil, nil, 4, 5, nil, ],
|
64
|
+
[ nil, nil, 6, 7, nil, nil, nil, nil, 15, ],
|
65
|
+
[ nil, nil, nil, nil, 8, 9, nil, nil, nil, ],
|
66
|
+
[ nil, nil, nil, nil, 8, 9, nil, nil, nil, ],
|
65
67
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
66
|
-
[ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
|
67
|
-
[ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
|
68
68
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
69
69
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
70
70
|
]
|
71
71
|
### Default Reduce Table
|
72
72
|
defred_table = [
|
73
|
-
nil,
|
74
73
|
nil,
|
75
74
|
nil,
|
76
75
|
-3,
|
@@ -81,17 +80,17 @@ class TinyCalc < Depager::LALR::Basis
|
|
81
80
|
nil,
|
82
81
|
nil,
|
83
82
|
nil,
|
84
|
-
|
83
|
+
nil,
|
85
84
|
-1,
|
86
85
|
-2,
|
87
86
|
-4,
|
88
87
|
-5,
|
88
|
+
-8,
|
89
89
|
]
|
90
90
|
defred_after_shift_table = [
|
91
91
|
nil,
|
92
92
|
nil,
|
93
93
|
nil,
|
94
|
-
nil,
|
95
94
|
-6,
|
96
95
|
-7,
|
97
96
|
nil,
|
@@ -99,11 +98,12 @@ class TinyCalc < Depager::LALR::Basis
|
|
99
98
|
nil,
|
100
99
|
nil,
|
101
100
|
nil,
|
102
|
-
|
101
|
+
nil,
|
103
102
|
nil,
|
104
103
|
nil,
|
105
104
|
-4,
|
106
105
|
-5,
|
106
|
+
-8,
|
107
107
|
]
|
108
108
|
### Nonterm to Int
|
109
109
|
nt2i = {
|
@@ -119,24 +119,206 @@ class TinyCalc < Depager::LALR::Basis
|
|
119
119
|
]
|
120
120
|
### Goto Table
|
121
121
|
goto_table = [
|
122
|
-
[ 2, 3,
|
123
|
-
[ 6, 3, 4, ],
|
122
|
+
[ 1, 2, 3, ],
|
124
123
|
[ nil, nil, nil, ],
|
125
124
|
[ nil, nil, nil, ],
|
126
125
|
[ nil, nil, nil, ],
|
127
126
|
[ nil, nil, nil, ],
|
128
|
-
[
|
129
|
-
[ nil,
|
130
|
-
[ nil,
|
127
|
+
[ 10, 2, 3, ],
|
128
|
+
[ nil, 11, 3, ],
|
129
|
+
[ nil, 12, 3, ],
|
130
|
+
[ nil, nil, 13, ],
|
131
131
|
[ nil, nil, 14, ],
|
132
|
-
[ nil, nil, 15, ],
|
133
132
|
[ nil, nil, nil, ],
|
134
133
|
[ nil, nil, nil, ],
|
135
134
|
[ nil, nil, nil, ],
|
136
135
|
[ nil, nil, nil, ],
|
137
136
|
[ nil, nil, nil, ],
|
137
|
+
[ nil, nil, nil, ],
|
138
|
+
]
|
139
|
+
|
140
|
+
|
141
|
+
alias orig_error error
|
142
|
+
def error
|
143
|
+
orig_error
|
144
|
+
warn "current state: #{StateInfo[@stack.last]}"
|
145
|
+
end
|
146
|
+
|
147
|
+
### States
|
148
|
+
StateInfo = [
|
149
|
+
<<'----------',
|
150
|
+
I000 =
|
151
|
+
( 0) $start : _ expr
|
152
|
+
|
153
|
+
NUM shift, and goto to state 4
|
154
|
+
'(' shift, and goto to state 5
|
155
|
+
|
156
|
+
|
157
|
+
----------
|
158
|
+
|
159
|
+
<<'----------',
|
160
|
+
I001 =
|
161
|
+
( 0) $start : expr _
|
162
|
+
( 1) expr : expr _ '+' term
|
163
|
+
( 2) expr : expr _ '-' term
|
164
|
+
|
165
|
+
'+' shift, and goto to state 6
|
166
|
+
'-' shift, and goto to state 7
|
167
|
+
|
168
|
+
|
169
|
+
$end accept
|
170
|
+
|
171
|
+
----------
|
172
|
+
|
173
|
+
<<'----------',
|
174
|
+
I002 =
|
175
|
+
( 3) expr : term _
|
176
|
+
( 4) term : term _ '*' fact
|
177
|
+
( 5) term : term _ '/' fact
|
178
|
+
|
179
|
+
'*' shift, and goto to state 8
|
180
|
+
'/' shift, and goto to state 9
|
181
|
+
|
182
|
+
$default reduce using rule 3 (expr)
|
183
|
+
|
184
|
+
----------
|
185
|
+
|
186
|
+
<<'----------',
|
187
|
+
I003 =
|
188
|
+
( 6) term : fact _
|
189
|
+
|
190
|
+
|
191
|
+
$default reduce using rule 6 (term) [after shift]
|
192
|
+
|
193
|
+
----------
|
194
|
+
|
195
|
+
<<'----------',
|
196
|
+
I004 =
|
197
|
+
( 7) fact : NUM _
|
198
|
+
|
199
|
+
|
200
|
+
$default reduce using rule 7 (fact) [after shift]
|
201
|
+
|
202
|
+
----------
|
203
|
+
|
204
|
+
<<'----------',
|
205
|
+
I005 =
|
206
|
+
( 8) fact : '(' _ expr ')'
|
207
|
+
|
208
|
+
NUM shift, and goto to state 4
|
209
|
+
'(' shift, and goto to state 5
|
210
|
+
|
211
|
+
|
212
|
+
----------
|
213
|
+
|
214
|
+
<<'----------',
|
215
|
+
I006 =
|
216
|
+
( 1) expr : expr '+' _ term
|
217
|
+
|
218
|
+
NUM shift, and goto to state 4
|
219
|
+
'(' shift, and goto to state 5
|
220
|
+
|
221
|
+
|
222
|
+
----------
|
223
|
+
|
224
|
+
<<'----------',
|
225
|
+
I007 =
|
226
|
+
( 2) expr : expr '-' _ term
|
227
|
+
|
228
|
+
NUM shift, and goto to state 4
|
229
|
+
'(' shift, and goto to state 5
|
230
|
+
|
231
|
+
|
232
|
+
----------
|
233
|
+
|
234
|
+
<<'----------',
|
235
|
+
I008 =
|
236
|
+
( 4) term : term '*' _ fact
|
237
|
+
|
238
|
+
NUM shift, and goto to state 4
|
239
|
+
'(' shift, and goto to state 5
|
240
|
+
|
241
|
+
|
242
|
+
----------
|
243
|
+
|
244
|
+
<<'----------',
|
245
|
+
I009 =
|
246
|
+
( 5) term : term '/' _ fact
|
247
|
+
|
248
|
+
NUM shift, and goto to state 4
|
249
|
+
'(' shift, and goto to state 5
|
250
|
+
|
251
|
+
|
252
|
+
----------
|
253
|
+
|
254
|
+
<<'----------',
|
255
|
+
I010 =
|
256
|
+
( 8) fact : '(' expr _ ')'
|
257
|
+
( 1) expr : expr _ '+' term
|
258
|
+
( 2) expr : expr _ '-' term
|
259
|
+
|
260
|
+
'+' shift, and goto to state 6
|
261
|
+
'-' shift, and goto to state 7
|
262
|
+
')' shift, and goto to state 15
|
263
|
+
|
264
|
+
|
265
|
+
----------
|
266
|
+
|
267
|
+
<<'----------',
|
268
|
+
I011 =
|
269
|
+
( 1) expr : expr '+' term _
|
270
|
+
( 4) term : term _ '*' fact
|
271
|
+
( 5) term : term _ '/' fact
|
272
|
+
|
273
|
+
'*' shift, and goto to state 8
|
274
|
+
'/' shift, and goto to state 9
|
275
|
+
|
276
|
+
$default reduce using rule 1 (expr)
|
277
|
+
|
278
|
+
----------
|
279
|
+
|
280
|
+
<<'----------',
|
281
|
+
I012 =
|
282
|
+
( 2) expr : expr '-' term _
|
283
|
+
( 4) term : term _ '*' fact
|
284
|
+
( 5) term : term _ '/' fact
|
285
|
+
|
286
|
+
'*' shift, and goto to state 8
|
287
|
+
'/' shift, and goto to state 9
|
288
|
+
|
289
|
+
$default reduce using rule 2 (expr)
|
290
|
+
|
291
|
+
----------
|
292
|
+
|
293
|
+
<<'----------',
|
294
|
+
I013 =
|
295
|
+
( 4) term : term '*' fact _
|
296
|
+
|
297
|
+
|
298
|
+
$default reduce using rule 4 (term) [after shift]
|
299
|
+
|
300
|
+
----------
|
301
|
+
|
302
|
+
<<'----------',
|
303
|
+
I014 =
|
304
|
+
( 5) term : term '/' fact _
|
305
|
+
|
306
|
+
|
307
|
+
$default reduce using rule 5 (term) [after shift]
|
308
|
+
|
309
|
+
----------
|
310
|
+
|
311
|
+
<<'----------',
|
312
|
+
I015 =
|
313
|
+
( 8) fact : '(' expr ')' _
|
314
|
+
|
315
|
+
|
316
|
+
$default reduce using rule 8 (fact) [after shift]
|
317
|
+
|
318
|
+
----------
|
138
319
|
]
|
139
320
|
|
321
|
+
|
140
322
|
Tables = [ reduce_table, nparams, action_table,
|
141
323
|
defred_table, defred_after_shift_table, goto_table,
|
142
324
|
t2i, i2t, nt2i, i2nt ]
|
@@ -181,7 +363,7 @@ end
|
|
181
363
|
|
182
364
|
class D4TinyCalc::NVAction < Depager::LALR::Action #:nodoc:all
|
183
365
|
include Depager::DecoratorUtils
|
184
|
-
|
366
|
+
[]
|
185
367
|
on_reduce = [
|
186
368
|
nil,
|
187
369
|
:_act_0,
|
@@ -202,77 +384,69 @@ class D4TinyCalc::NVAction < Depager::LALR::Action #:nodoc:all
|
|
202
384
|
end
|
203
385
|
|
204
386
|
|
205
|
-
module_eval <<-'.,.,
|
206
|
-
|
207
|
-
_expr, _, _term = *val
|
387
|
+
module_eval <<-'.,.,120998293534507.,.,', 'sample_calc/calc.nvaction.dr', 14
|
388
|
+
def _act_0 val
|
389
|
+
_expr, _, _term, = *val
|
208
390
|
_expr + _term
|
209
391
|
|
210
|
-
|
211
|
-
|
212
|
-
.,.,11875410918262.,.,
|
392
|
+
end
|
393
|
+
.,.,120998293534507.,.,
|
213
394
|
|
214
|
-
module_eval <<-'.,.,
|
215
|
-
|
216
|
-
_expr, _, _term = *val
|
395
|
+
module_eval <<-'.,.,120998293543793.,.,', 'sample_calc/calc.nvaction.dr', 15
|
396
|
+
def _act_1 val
|
397
|
+
_expr, _, _term, = *val
|
217
398
|
_expr - _term
|
218
399
|
|
219
|
-
|
220
|
-
|
221
|
-
.,.,1187541091927.,.,
|
400
|
+
end
|
401
|
+
.,.,120998293543793.,.,
|
222
402
|
|
223
|
-
module_eval <<-'.,.,
|
224
|
-
|
225
|
-
_term = *val
|
403
|
+
module_eval <<-'.,.,12099829356139.,.,', 'sample_calc/calc.nvaction.dr', 16
|
404
|
+
def _act_2 val
|
405
|
+
_term, = *val
|
226
406
|
_term
|
227
407
|
|
228
|
-
|
229
|
-
|
230
|
-
.,.,118754109144413.,.,
|
408
|
+
end
|
409
|
+
.,.,12099829356139.,.,
|
231
410
|
|
232
|
-
module_eval <<-'.,.,
|
233
|
-
|
234
|
-
_term, _, _fact = *val
|
411
|
+
module_eval <<-'.,.,120998293556044.,.,', 'sample_calc/calc.nvaction.dr', 19
|
412
|
+
def _act_3 val
|
413
|
+
_term, _, _fact, = *val
|
235
414
|
_term * _fact
|
236
415
|
|
237
|
-
|
238
|
-
|
239
|
-
.,.,118754109140027.,.,
|
416
|
+
end
|
417
|
+
.,.,120998293556044.,.,
|
240
418
|
|
241
|
-
module_eval <<-'.,.,
|
242
|
-
|
243
|
-
_term, _, _fact = *val
|
419
|
+
module_eval <<-'.,.,120998293536062.,.,', 'sample_calc/calc.nvaction.dr', 20
|
420
|
+
def _act_4 val
|
421
|
+
_term, _, _fact, = *val
|
244
422
|
_term / _fact
|
245
423
|
|
246
|
-
|
247
|
-
|
248
|
-
.,.,118754109114448.,.,
|
424
|
+
end
|
425
|
+
.,.,120998293536062.,.,
|
249
426
|
|
250
|
-
module_eval <<-'.,.,
|
251
|
-
|
252
|
-
_fact = *val
|
427
|
+
module_eval <<-'.,.,12099829353784.,.,', 'sample_calc/calc.nvaction.dr', 21
|
428
|
+
def _act_5 val
|
429
|
+
_fact, = *val
|
253
430
|
_fact
|
254
431
|
|
255
|
-
|
256
|
-
|
257
|
-
.,.,11875410913851.,.,
|
432
|
+
end
|
433
|
+
.,.,12099829353784.,.,
|
258
434
|
|
259
|
-
module_eval <<-'.,.,
|
260
|
-
|
261
|
-
_NUM = *val
|
435
|
+
module_eval <<-'.,.,120998293538888.,.,', 'sample_calc/calc.nvaction.dr', 24
|
436
|
+
def _act_6 val
|
437
|
+
_NUM, = *val
|
262
438
|
_NUM.value
|
263
439
|
|
264
|
-
|
265
|
-
|
266
|
-
.,.,118754109131622.,.,
|
440
|
+
end
|
441
|
+
.,.,120998293538888.,.,
|
267
442
|
|
268
|
-
module_eval <<-'.,.,
|
269
|
-
|
270
|
-
_, _expr, _ = *val
|
443
|
+
module_eval <<-'.,.,120998293537392.,.,', 'sample_calc/calc.nvaction.dr', 25
|
444
|
+
def _act_7 val
|
445
|
+
_, _expr, _, = *val
|
271
446
|
_expr
|
272
447
|
|
273
|
-
|
274
|
-
|
275
|
-
.,.,118754109111174.,.,
|
448
|
+
end
|
449
|
+
.,.,120998293537392.,.,
|
276
450
|
|
277
451
|
end
|
278
452
|
|