depager 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- 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,11 +12,11 @@ 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 + expr
|
16
|
-
[ 0, 3 ], # ( 2) expr : expr - expr
|
17
|
-
[ 0, 3 ], # ( 3) expr : expr * expr
|
18
|
-
[ 0, 3 ], # ( 4) expr : expr / expr
|
19
|
-
[ 0, 3 ], # ( 5) expr : ( expr )
|
15
|
+
[ 0, 3 ], # ( 1) expr : expr '+' expr
|
16
|
+
[ 0, 3 ], # ( 2) expr : expr '-' expr
|
17
|
+
[ 0, 3 ], # ( 3) expr : expr '*' expr
|
18
|
+
[ 0, 3 ], # ( 4) expr : expr '/' expr
|
19
|
+
[ 0, 3 ], # ( 5) expr : '(' expr ')'
|
20
20
|
[ 0, 1 ], # ( 6) expr : NUM
|
21
21
|
]
|
22
22
|
### Extension Params
|
@@ -50,18 +50,18 @@ class TinyCalc < Depager::LALR::Basis
|
|
50
50
|
### Action Table
|
51
51
|
action_table = [
|
52
52
|
[ nil, nil, nil, nil, nil, nil, 2, nil, 3, ],
|
53
|
-
[ ACC, nil,
|
53
|
+
[ ACC, nil, 4, 5, 6, 7, nil, nil, nil, ],
|
54
54
|
[ nil, nil, nil, nil, nil, nil, 2, nil, 3, ],
|
55
55
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
56
56
|
[ nil, nil, nil, nil, nil, nil, 2, nil, 3, ],
|
57
57
|
[ nil, nil, nil, nil, nil, nil, 2, nil, 3, ],
|
58
58
|
[ nil, nil, nil, nil, nil, nil, 2, nil, 3, ],
|
59
59
|
[ nil, nil, nil, nil, nil, nil, 2, nil, 3, ],
|
60
|
-
[ nil, nil,
|
61
|
-
[ nil, nil, nil, nil,
|
60
|
+
[ nil, nil, 4, 5, 6, 7, nil, 13, nil, ],
|
61
|
+
[ nil, nil, nil, nil, 6, 7, nil, nil, nil, ],
|
62
|
+
[ nil, nil, nil, nil, 6, 7, nil, nil, nil, ],
|
62
63
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
63
64
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
64
|
-
[ nil, nil, nil, nil, 5, 6, nil, nil, nil, ],
|
65
65
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
66
66
|
]
|
67
67
|
### Default Reduce Table
|
@@ -75,10 +75,10 @@ class TinyCalc < Depager::LALR::Basis
|
|
75
75
|
nil,
|
76
76
|
nil,
|
77
77
|
nil,
|
78
|
+
-1,
|
78
79
|
-2,
|
79
80
|
-3,
|
80
81
|
-4,
|
81
|
-
-1,
|
82
82
|
-5,
|
83
83
|
]
|
84
84
|
defred_after_shift_table = [
|
@@ -92,9 +92,9 @@ class TinyCalc < Depager::LALR::Basis
|
|
92
92
|
nil,
|
93
93
|
nil,
|
94
94
|
nil,
|
95
|
+
nil,
|
95
96
|
-3,
|
96
97
|
-4,
|
97
|
-
nil,
|
98
98
|
-5,
|
99
99
|
]
|
100
100
|
### Nonterm to Int
|
@@ -123,6 +123,186 @@ class TinyCalc < Depager::LALR::Basis
|
|
123
123
|
[ nil, ],
|
124
124
|
]
|
125
125
|
|
126
|
+
|
127
|
+
alias orig_error error
|
128
|
+
def error
|
129
|
+
orig_error
|
130
|
+
warn "current state: #{StateInfo[@stack.last]}"
|
131
|
+
end
|
132
|
+
|
133
|
+
### States
|
134
|
+
StateInfo = [
|
135
|
+
<<'----------',
|
136
|
+
I000 =
|
137
|
+
( 0) $start : _ expr
|
138
|
+
|
139
|
+
'(' shift, and goto to state 2
|
140
|
+
NUM shift, and goto to state 3
|
141
|
+
|
142
|
+
|
143
|
+
----------
|
144
|
+
|
145
|
+
<<'----------',
|
146
|
+
I001 =
|
147
|
+
( 0) $start : expr _
|
148
|
+
( 1) expr : expr _ '+' expr
|
149
|
+
( 2) expr : expr _ '-' expr
|
150
|
+
( 3) expr : expr _ '*' expr
|
151
|
+
( 4) expr : expr _ '/' expr
|
152
|
+
|
153
|
+
'+' shift, and goto to state 4
|
154
|
+
'-' shift, and goto to state 5
|
155
|
+
'*' shift, and goto to state 6
|
156
|
+
'/' shift, and goto to state 7
|
157
|
+
|
158
|
+
|
159
|
+
$end accept
|
160
|
+
|
161
|
+
----------
|
162
|
+
|
163
|
+
<<'----------',
|
164
|
+
I002 =
|
165
|
+
( 5) expr : '(' _ expr ')'
|
166
|
+
|
167
|
+
'(' shift, and goto to state 2
|
168
|
+
NUM shift, and goto to state 3
|
169
|
+
|
170
|
+
|
171
|
+
----------
|
172
|
+
|
173
|
+
<<'----------',
|
174
|
+
I003 =
|
175
|
+
( 6) expr : NUM _
|
176
|
+
|
177
|
+
|
178
|
+
$default reduce using rule 6 (expr) [after shift]
|
179
|
+
|
180
|
+
----------
|
181
|
+
|
182
|
+
<<'----------',
|
183
|
+
I004 =
|
184
|
+
( 1) expr : expr '+' _ expr
|
185
|
+
|
186
|
+
'(' shift, and goto to state 2
|
187
|
+
NUM shift, and goto to state 3
|
188
|
+
|
189
|
+
|
190
|
+
----------
|
191
|
+
|
192
|
+
<<'----------',
|
193
|
+
I005 =
|
194
|
+
( 2) expr : expr '-' _ expr
|
195
|
+
|
196
|
+
'(' shift, and goto to state 2
|
197
|
+
NUM shift, and goto to state 3
|
198
|
+
|
199
|
+
|
200
|
+
----------
|
201
|
+
|
202
|
+
<<'----------',
|
203
|
+
I006 =
|
204
|
+
( 3) expr : expr '*' _ expr
|
205
|
+
|
206
|
+
'(' shift, and goto to state 2
|
207
|
+
NUM shift, and goto to state 3
|
208
|
+
|
209
|
+
|
210
|
+
----------
|
211
|
+
|
212
|
+
<<'----------',
|
213
|
+
I007 =
|
214
|
+
( 4) expr : expr '/' _ expr
|
215
|
+
|
216
|
+
'(' shift, and goto to state 2
|
217
|
+
NUM shift, and goto to state 3
|
218
|
+
|
219
|
+
|
220
|
+
----------
|
221
|
+
|
222
|
+
<<'----------',
|
223
|
+
I008 =
|
224
|
+
( 5) expr : '(' expr _ ')'
|
225
|
+
( 1) expr : expr _ '+' expr
|
226
|
+
( 2) expr : expr _ '-' expr
|
227
|
+
( 3) expr : expr _ '*' expr
|
228
|
+
( 4) expr : expr _ '/' expr
|
229
|
+
|
230
|
+
'+' shift, and goto to state 4
|
231
|
+
'-' shift, and goto to state 5
|
232
|
+
'*' shift, and goto to state 6
|
233
|
+
'/' shift, and goto to state 7
|
234
|
+
')' shift, and goto to state 13
|
235
|
+
|
236
|
+
|
237
|
+
----------
|
238
|
+
|
239
|
+
<<'----------',
|
240
|
+
I009 =
|
241
|
+
( 1) expr : expr '+' expr _
|
242
|
+
( 1) expr : expr _ '+' expr
|
243
|
+
( 2) expr : expr _ '-' expr
|
244
|
+
( 3) expr : expr _ '*' expr
|
245
|
+
( 4) expr : expr _ '/' expr
|
246
|
+
|
247
|
+
'*' shift, and goto to state 6
|
248
|
+
'/' shift, and goto to state 7
|
249
|
+
|
250
|
+
$default reduce using rule 1 (expr)
|
251
|
+
|
252
|
+
----------
|
253
|
+
|
254
|
+
<<'----------',
|
255
|
+
I010 =
|
256
|
+
( 2) expr : expr '-' expr _
|
257
|
+
( 1) expr : expr _ '+' expr
|
258
|
+
( 2) expr : expr _ '-' expr
|
259
|
+
( 3) expr : expr _ '*' expr
|
260
|
+
( 4) expr : expr _ '/' expr
|
261
|
+
|
262
|
+
'*' shift, and goto to state 6
|
263
|
+
'/' shift, and goto to state 7
|
264
|
+
|
265
|
+
$default reduce using rule 2 (expr)
|
266
|
+
|
267
|
+
----------
|
268
|
+
|
269
|
+
<<'----------',
|
270
|
+
I011 =
|
271
|
+
( 3) expr : expr '*' expr _
|
272
|
+
( 1) expr : expr _ '+' expr
|
273
|
+
( 2) expr : expr _ '-' expr
|
274
|
+
( 3) expr : expr _ '*' expr
|
275
|
+
( 4) expr : expr _ '/' expr
|
276
|
+
|
277
|
+
|
278
|
+
$default reduce using rule 3 (expr) [after shift]
|
279
|
+
|
280
|
+
----------
|
281
|
+
|
282
|
+
<<'----------',
|
283
|
+
I012 =
|
284
|
+
( 4) expr : expr '/' expr _
|
285
|
+
( 1) expr : expr _ '+' expr
|
286
|
+
( 2) expr : expr _ '-' expr
|
287
|
+
( 3) expr : expr _ '*' expr
|
288
|
+
( 4) expr : expr _ '/' expr
|
289
|
+
|
290
|
+
|
291
|
+
$default reduce using rule 4 (expr) [after shift]
|
292
|
+
|
293
|
+
----------
|
294
|
+
|
295
|
+
<<'----------',
|
296
|
+
I013 =
|
297
|
+
( 5) expr : '(' expr ')' _
|
298
|
+
|
299
|
+
|
300
|
+
$default reduce using rule 5 (expr) [after shift]
|
301
|
+
|
302
|
+
----------
|
303
|
+
]
|
304
|
+
|
305
|
+
|
126
306
|
Tables = [ reduce_table, nparams, action_table,
|
127
307
|
defred_table, defred_after_shift_table, goto_table,
|
128
308
|
t2i, i2t, nt2i, i2nt ]
|
@@ -167,7 +347,7 @@ end
|
|
167
347
|
|
168
348
|
class D4TinyCalc::NVAction < Depager::LALR::Action #:nodoc:all
|
169
349
|
include Depager::DecoratorUtils
|
170
|
-
|
350
|
+
[]
|
171
351
|
on_reduce = [
|
172
352
|
nil,
|
173
353
|
:_act_0,
|
@@ -186,59 +366,53 @@ class D4TinyCalc::NVAction < Depager::LALR::Action #:nodoc:all
|
|
186
366
|
end
|
187
367
|
|
188
368
|
|
189
|
-
module_eval <<-'.,.,
|
190
|
-
|
191
|
-
_left, _, _right = *val
|
369
|
+
module_eval <<-'.,.,120998293532945.,.,', 'sample_calc/calc_prec.nvaction.dr', 18
|
370
|
+
def _act_0 val
|
371
|
+
_left, _, _right, = *val
|
192
372
|
_left + _right
|
193
373
|
|
194
|
-
|
195
|
-
|
196
|
-
.,.,118754109222632.,.,
|
374
|
+
end
|
375
|
+
.,.,120998293532945.,.,
|
197
376
|
|
198
|
-
module_eval <<-'.,.,
|
199
|
-
|
200
|
-
_left, _, _right = *val
|
377
|
+
module_eval <<-'.,.,120998293512295.,.,', 'sample_calc/calc_prec.nvaction.dr', 19
|
378
|
+
def _act_1 val
|
379
|
+
_left, _, _right, = *val
|
201
380
|
_left - _right
|
202
381
|
|
203
|
-
|
204
|
-
|
205
|
-
.,.,118754109254894.,.,
|
382
|
+
end
|
383
|
+
.,.,120998293512295.,.,
|
206
384
|
|
207
|
-
module_eval <<-'.,.,
|
208
|
-
|
209
|
-
_left, _, _right = *val
|
385
|
+
module_eval <<-'.,.,120998293533739.,.,', 'sample_calc/calc_prec.nvaction.dr', 20
|
386
|
+
def _act_2 val
|
387
|
+
_left, _, _right, = *val
|
210
388
|
_left * _right
|
211
389
|
|
212
|
-
|
213
|
-
|
214
|
-
.,.,118754109239243.,.,
|
390
|
+
end
|
391
|
+
.,.,120998293533739.,.,
|
215
392
|
|
216
|
-
module_eval <<-'.,.,
|
217
|
-
|
218
|
-
_left, _, _right = *val
|
393
|
+
module_eval <<-'.,.,120998293551299.,.,', 'sample_calc/calc_prec.nvaction.dr', 21
|
394
|
+
def _act_3 val
|
395
|
+
_left, _, _right, = *val
|
219
396
|
_left / _right
|
220
397
|
|
221
|
-
|
222
|
-
|
223
|
-
.,.,118754109238225.,.,
|
398
|
+
end
|
399
|
+
.,.,120998293551299.,.,
|
224
400
|
|
225
|
-
module_eval <<-'.,.,
|
226
|
-
|
227
|
-
_, _expr, _ = *val
|
401
|
+
module_eval <<-'.,.,120998293522595.,.,', 'sample_calc/calc_prec.nvaction.dr', 22
|
402
|
+
def _act_4 val
|
403
|
+
_, _expr, _, = *val
|
228
404
|
_expr
|
229
405
|
|
230
|
-
|
231
|
-
|
232
|
-
.,.,118754109226405.,.,
|
406
|
+
end
|
407
|
+
.,.,120998293522595.,.,
|
233
408
|
|
234
|
-
module_eval <<-'.,.,
|
235
|
-
|
236
|
-
_NUM = *val
|
409
|
+
module_eval <<-'.,.,120998293547470.,.,', 'sample_calc/calc_prec.nvaction.dr', 23
|
410
|
+
def _act_5 val
|
411
|
+
_NUM, = *val
|
237
412
|
_NUM.value
|
238
413
|
|
239
|
-
|
240
|
-
|
241
|
-
.,.,118754109237470.,.,
|
414
|
+
end
|
415
|
+
.,.,120998293547470.,.,
|
242
416
|
|
243
417
|
end
|
244
418
|
|