depager 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/README.ja +27 -28
- data/examples/c89/c89.dr +34 -34
- data/examples/c89/c89.tab.rb +3074 -3074
- data/examples/extension/paction.dr +4 -4
- data/examples/extension/pactiontest.dr +1 -1
- data/examples/pl0d/pl0ds.dr +27 -27
- data/examples/pl0d/pl0ds.tab.rb +626 -643
- data/examples/sample_calc/calc.action.dr +6 -6
- data/examples/sample_calc/calc.action.tab.rb +90 -90
- data/examples/sample_calc/calc.ast.action.dr +7 -7
- data/examples/sample_calc/calc.ast.action.tab.rb +121 -127
- data/examples/sample_calc/calc.ast.dr +6 -6
- data/examples/sample_calc/calc.ast.tab.rb +102 -109
- data/examples/sample_calc/calc.astdf.dr +6 -6
- data/examples/sample_calc/calc.astdf.tab.rb +102 -109
- data/examples/sample_calc/calc.atree.dr +6 -6
- data/examples/sample_calc/calc.atree.tab.rb +90 -90
- data/examples/sample_calc/calc.cst.dr +5 -5
- data/examples/sample_calc/calc.cst.tab.rb +106 -106
- data/examples/sample_calc/calc.dr +1 -1
- data/examples/sample_calc/calc.lex.dr +4 -4
- data/examples/sample_calc/calc.lex.tab.rb +73 -73
- data/examples/sample_calc/calc.nvaction.dr +6 -6
- data/examples/sample_calc/calc.nvaction.tab.rb +90 -90
- data/examples/sample_calc/calc.tab.rb +71 -71
- data/examples/sample_calc/calc_prec.nvaction.dr +6 -6
- data/examples/sample_calc/calc_prec.nvaction.tab.rb +46 -46
- data/examples/slex_test/divreg.slex.dr +7 -7
- data/examples/slex_test/divreg.slex.tab.rb +20 -20
- data/examples/slex_test/ljoin.slex.dr +7 -7
- data/examples/slex_test/ljoin.slex.tab.rb +15 -15
- data/lib/depager.rb +45 -83
- data/lib/depager/grammar.rb +3 -7
- data/lib/depager/lr.rb +123 -1
- data/lib/depager/parser.rb +29 -48
- data/lib/depager/{template/ast.erbs → ruby/plugins/_ast_tmpl.rb} +11 -7
- data/lib/depager/{action.rb → ruby/plugins/action.rb} +7 -11
- data/lib/depager/{ast.dr → ruby/plugins/ast.dr} +24 -25
- data/lib/depager/{ast.rb → ruby/plugins/ast.rb} +241 -243
- data/lib/depager/{astdf.rb → ruby/plugins/astdf.rb} +1 -2
- data/lib/depager/{atree.dr → ruby/plugins/atree.dr} +5 -5
- data/lib/depager/{atree.rb → ruby/plugins/atree.rb} +39 -39
- data/lib/depager/{cst.dr → ruby/plugins/cst.dr} +17 -21
- data/lib/depager/{cst.rb → ruby/plugins/cst.rb} +62 -68
- data/lib/depager/{lex.dr → ruby/plugins/lex.dr} +3 -4
- data/lib/depager/{lex.rb → ruby/plugins/lex.rb} +29 -31
- data/lib/depager/{nvaction.rb → ruby/plugins/nvaction.rb} +1 -3
- data/lib/depager/{slex.dr → ruby/plugins/slex.dr} +16 -17
- data/lib/depager/{slex.rb → ruby/plugins/slex.rb} +115 -117
- data/lib/depager/{srp.rb → ruby/plugins/srp.rb} +4 -4
- data/lib/depager/{template → ruby/templates}/extension_lalr_master.erb +6 -6
- data/lib/depager/{template → ruby/templates}/extension_lalr_slave.erb +0 -0
- data/lib/depager/{template → ruby/templates}/simple.erb +0 -0
- data/lib/depager/{template → ruby/templates}/single_lalr_parser.erb +0 -0
- data/lib/depager/utils.rb +30 -69
- data/lib/depager/version.rb +1 -1
- metadata +59 -56
- data/examples/Rakefile +0 -36
- data/lib/depager/Rakefile +0 -34
- data/lib/depager/lr_put_table.rb +0 -116
- data/lib/depager/parse_action.rb +0 -24
@@ -24,8 +24,8 @@ class TinyCalc < Depager::LALR::Basis
|
|
24
24
|
]
|
25
25
|
### Extension Params
|
26
26
|
nparams = {
|
27
|
-
'ASTBuilder' => 2,
|
28
27
|
'Action' => 3,
|
28
|
+
'ASTBuilder' => 2,
|
29
29
|
}
|
30
30
|
### Term to Int
|
31
31
|
t2i = {
|
@@ -53,25 +53,26 @@ class TinyCalc < Depager::LALR::Basis
|
|
53
53
|
]
|
54
54
|
### Action Table
|
55
55
|
action_table = [
|
56
|
-
[ nil, nil, nil, nil, nil, nil,
|
57
|
-
[
|
58
|
-
[
|
56
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
57
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
58
|
+
[ ACC, nil, 7, 8, nil, nil, nil, nil, nil, ],
|
59
|
+
[ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
|
59
60
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
60
61
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
61
|
-
[ nil, nil,
|
62
|
-
[ nil, nil, nil, nil, nil, nil,
|
63
|
-
[ nil, nil, nil, nil, nil, nil,
|
64
|
-
[ nil, nil, nil, nil, nil, nil,
|
65
|
-
[ nil, nil, nil, nil, nil, nil,
|
66
|
-
[ nil, nil, 6, 7, nil, nil, nil, nil, 15, ],
|
67
|
-
[ nil, nil, nil, nil, 8, 9, nil, nil, nil, ],
|
68
|
-
[ nil, nil, nil, nil, 8, 9, nil, nil, nil, ],
|
62
|
+
[ nil, nil, 7, 8, nil, nil, nil, nil, 11, ],
|
63
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
64
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
65
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
66
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
69
67
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
68
|
+
[ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
|
69
|
+
[ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
|
70
70
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
71
71
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
72
72
|
]
|
73
73
|
### Default Reduce Table
|
74
74
|
defred_table = [
|
75
|
+
nil,
|
75
76
|
nil,
|
76
77
|
nil,
|
77
78
|
-3,
|
@@ -82,17 +83,17 @@ class TinyCalc < Depager::LALR::Basis
|
|
82
83
|
nil,
|
83
84
|
nil,
|
84
85
|
nil,
|
85
|
-
|
86
|
+
-8,
|
86
87
|
-1,
|
87
88
|
-2,
|
88
89
|
-4,
|
89
90
|
-5,
|
90
|
-
-8,
|
91
91
|
]
|
92
92
|
defred_after_shift_table = [
|
93
93
|
nil,
|
94
94
|
nil,
|
95
95
|
nil,
|
96
|
+
nil,
|
96
97
|
-6,
|
97
98
|
-7,
|
98
99
|
nil,
|
@@ -100,12 +101,11 @@ class TinyCalc < Depager::LALR::Basis
|
|
100
101
|
nil,
|
101
102
|
nil,
|
102
103
|
nil,
|
103
|
-
|
104
|
+
-8,
|
104
105
|
nil,
|
105
106
|
nil,
|
106
107
|
-4,
|
107
108
|
-5,
|
108
|
-
-8,
|
109
109
|
]
|
110
110
|
### Nonterm to Int
|
111
111
|
nt2i = {
|
@@ -121,17 +121,17 @@ class TinyCalc < Depager::LALR::Basis
|
|
121
121
|
]
|
122
122
|
### Goto Table
|
123
123
|
goto_table = [
|
124
|
-
[
|
124
|
+
[ 2, 3, 4, ],
|
125
|
+
[ 6, 3, 4, ],
|
125
126
|
[ nil, nil, nil, ],
|
126
127
|
[ nil, nil, nil, ],
|
127
128
|
[ nil, nil, nil, ],
|
128
129
|
[ nil, nil, nil, ],
|
129
|
-
[ 10, 2, 3, ],
|
130
|
-
[ nil, 11, 3, ],
|
131
|
-
[ nil, 12, 3, ],
|
132
|
-
[ nil, nil, 13, ],
|
133
|
-
[ nil, nil, 14, ],
|
134
130
|
[ nil, nil, nil, ],
|
131
|
+
[ nil, 12, 4, ],
|
132
|
+
[ nil, 13, 4, ],
|
133
|
+
[ nil, nil, 14, ],
|
134
|
+
[ nil, nil, 15, ],
|
135
135
|
[ nil, nil, nil, ],
|
136
136
|
[ nil, nil, nil, ],
|
137
137
|
[ nil, nil, nil, ],
|
@@ -152,20 +152,30 @@ class TinyCalc < Depager::LALR::Basis
|
|
152
152
|
I000 =
|
153
153
|
( 0) $start : _ expr
|
154
154
|
|
155
|
-
NUM shift, and goto to state
|
156
|
-
'(' shift, and goto to state
|
155
|
+
NUM shift, and goto to state 5
|
156
|
+
'(' shift, and goto to state 1
|
157
157
|
|
158
158
|
|
159
159
|
----------
|
160
160
|
|
161
161
|
<<'----------',
|
162
162
|
I001 =
|
163
|
+
( 8) fact : '(' _ expr ')'
|
164
|
+
|
165
|
+
NUM shift, and goto to state 5
|
166
|
+
'(' shift, and goto to state 1
|
167
|
+
|
168
|
+
|
169
|
+
----------
|
170
|
+
|
171
|
+
<<'----------',
|
172
|
+
I002 =
|
163
173
|
( 0) $start : expr _
|
164
174
|
( 1) expr : expr _ '+' term
|
165
175
|
( 2) expr : expr _ '-' term
|
166
176
|
|
167
|
-
'+' shift, and goto to state
|
168
|
-
'-' shift, and goto to state
|
177
|
+
'+' shift, and goto to state 7
|
178
|
+
'-' shift, and goto to state 8
|
169
179
|
|
170
180
|
|
171
181
|
$end accept
|
@@ -173,20 +183,20 @@ I001 =
|
|
173
183
|
----------
|
174
184
|
|
175
185
|
<<'----------',
|
176
|
-
|
186
|
+
I003 =
|
177
187
|
( 3) expr : term _
|
178
188
|
( 4) term : term _ '*' fact
|
179
189
|
( 5) term : term _ '/' fact
|
180
190
|
|
181
|
-
'*' shift, and goto to state
|
182
|
-
'/' shift, and goto to state
|
191
|
+
'*' shift, and goto to state 9
|
192
|
+
'/' shift, and goto to state 10
|
183
193
|
|
184
194
|
$default reduce using rule 3 (expr)
|
185
195
|
|
186
196
|
----------
|
187
197
|
|
188
198
|
<<'----------',
|
189
|
-
|
199
|
+
I004 =
|
190
200
|
( 6) term : fact _
|
191
201
|
|
192
202
|
|
@@ -195,7 +205,7 @@ I003 =
|
|
195
205
|
----------
|
196
206
|
|
197
207
|
<<'----------',
|
198
|
-
|
208
|
+
I005 =
|
199
209
|
( 7) fact : NUM _
|
200
210
|
|
201
211
|
|
@@ -204,96 +214,95 @@ I004 =
|
|
204
214
|
----------
|
205
215
|
|
206
216
|
<<'----------',
|
207
|
-
|
208
|
-
( 8) fact : '(' _
|
217
|
+
I006 =
|
218
|
+
( 8) fact : '(' expr _ ')'
|
219
|
+
( 1) expr : expr _ '+' term
|
220
|
+
( 2) expr : expr _ '-' term
|
209
221
|
|
210
|
-
|
211
|
-
'
|
222
|
+
'+' shift, and goto to state 7
|
223
|
+
'-' shift, and goto to state 8
|
224
|
+
')' shift, and goto to state 11
|
212
225
|
|
213
226
|
|
214
227
|
----------
|
215
228
|
|
216
229
|
<<'----------',
|
217
|
-
|
230
|
+
I007 =
|
218
231
|
( 1) expr : expr '+' _ term
|
219
232
|
|
220
|
-
NUM shift, and goto to state
|
221
|
-
'(' shift, and goto to state
|
233
|
+
NUM shift, and goto to state 5
|
234
|
+
'(' shift, and goto to state 1
|
222
235
|
|
223
236
|
|
224
237
|
----------
|
225
238
|
|
226
239
|
<<'----------',
|
227
|
-
|
240
|
+
I008 =
|
228
241
|
( 2) expr : expr '-' _ term
|
229
242
|
|
230
|
-
NUM shift, and goto to state
|
231
|
-
'(' shift, and goto to state
|
243
|
+
NUM shift, and goto to state 5
|
244
|
+
'(' shift, and goto to state 1
|
232
245
|
|
233
246
|
|
234
247
|
----------
|
235
248
|
|
236
249
|
<<'----------',
|
237
|
-
|
250
|
+
I009 =
|
238
251
|
( 4) term : term '*' _ fact
|
239
252
|
|
240
|
-
NUM shift, and goto to state
|
241
|
-
'(' shift, and goto to state
|
253
|
+
NUM shift, and goto to state 5
|
254
|
+
'(' shift, and goto to state 1
|
242
255
|
|
243
256
|
|
244
257
|
----------
|
245
258
|
|
246
259
|
<<'----------',
|
247
|
-
|
260
|
+
I010 =
|
248
261
|
( 5) term : term '/' _ fact
|
249
262
|
|
250
|
-
NUM shift, and goto to state
|
251
|
-
'(' shift, and goto to state
|
263
|
+
NUM shift, and goto to state 5
|
264
|
+
'(' shift, and goto to state 1
|
252
265
|
|
253
266
|
|
254
267
|
----------
|
255
268
|
|
256
269
|
<<'----------',
|
257
|
-
|
258
|
-
( 8) fact : '(' expr
|
259
|
-
( 1) expr : expr _ '+' term
|
260
|
-
( 2) expr : expr _ '-' term
|
270
|
+
I011 =
|
271
|
+
( 8) fact : '(' expr ')' _
|
261
272
|
|
262
|
-
'+' shift, and goto to state 6
|
263
|
-
'-' shift, and goto to state 7
|
264
|
-
')' shift, and goto to state 15
|
265
273
|
|
274
|
+
$default reduce using rule 8 (fact) [after shift]
|
266
275
|
|
267
276
|
----------
|
268
277
|
|
269
278
|
<<'----------',
|
270
|
-
|
279
|
+
I012 =
|
271
280
|
( 1) expr : expr '+' term _
|
272
281
|
( 4) term : term _ '*' fact
|
273
282
|
( 5) term : term _ '/' fact
|
274
283
|
|
275
|
-
'*' shift, and goto to state
|
276
|
-
'/' shift, and goto to state
|
284
|
+
'*' shift, and goto to state 9
|
285
|
+
'/' shift, and goto to state 10
|
277
286
|
|
278
287
|
$default reduce using rule 1 (expr)
|
279
288
|
|
280
289
|
----------
|
281
290
|
|
282
291
|
<<'----------',
|
283
|
-
|
292
|
+
I013 =
|
284
293
|
( 2) expr : expr '-' term _
|
285
294
|
( 4) term : term _ '*' fact
|
286
295
|
( 5) term : term _ '/' fact
|
287
296
|
|
288
|
-
'*' shift, and goto to state
|
289
|
-
'/' shift, and goto to state
|
297
|
+
'*' shift, and goto to state 9
|
298
|
+
'/' shift, and goto to state 10
|
290
299
|
|
291
300
|
$default reduce using rule 2 (expr)
|
292
301
|
|
293
302
|
----------
|
294
303
|
|
295
304
|
<<'----------',
|
296
|
-
|
305
|
+
I014 =
|
297
306
|
( 4) term : term '*' fact _
|
298
307
|
|
299
308
|
|
@@ -302,21 +311,12 @@ I013 =
|
|
302
311
|
----------
|
303
312
|
|
304
313
|
<<'----------',
|
305
|
-
|
314
|
+
I015 =
|
306
315
|
( 5) term : term '/' fact _
|
307
316
|
|
308
317
|
|
309
318
|
$default reduce using rule 5 (term) [after shift]
|
310
319
|
|
311
|
-
----------
|
312
|
-
|
313
|
-
<<'----------',
|
314
|
-
I015 =
|
315
|
-
( 8) fact : '(' expr ')' _
|
316
|
-
|
317
|
-
|
318
|
-
$default reduce using rule 8 (fact) [after shift]
|
319
|
-
|
320
320
|
----------
|
321
321
|
]
|
322
322
|
|
@@ -343,12 +343,12 @@ I015 =
|
|
343
343
|
|
344
344
|
when /\A[1-9][0-9]*/
|
345
345
|
@oldline = @line; @line = $'
|
346
|
-
yield
|
346
|
+
yield token(:NUM, $&.to_i)
|
347
347
|
|
348
348
|
|
349
349
|
when /\A./
|
350
350
|
@oldline = @line; @line = $'
|
351
|
-
yield
|
351
|
+
yield token($&, $&)
|
352
352
|
|
353
353
|
|
354
354
|
else
|
@@ -362,7 +362,6 @@ I015 =
|
|
362
362
|
end
|
363
363
|
|
364
364
|
### Outer Code
|
365
|
-
|
366
365
|
class Node
|
367
366
|
attr_accessor :lineno
|
368
367
|
attr_accessor :value
|
@@ -419,8 +418,6 @@ class NilNode
|
|
419
418
|
def accept v
|
420
419
|
end
|
421
420
|
end
|
422
|
-
|
423
|
-
|
424
421
|
class Node_add < Node
|
425
422
|
attr_accessor :left, :right
|
426
423
|
attr_accessor
|
@@ -439,7 +436,6 @@ class Node_add < Node
|
|
439
436
|
self
|
440
437
|
end
|
441
438
|
end
|
442
|
-
|
443
439
|
class Node_sub < Node
|
444
440
|
attr_accessor :left, :right
|
445
441
|
attr_accessor
|
@@ -458,7 +454,6 @@ class Node_sub < Node
|
|
458
454
|
self
|
459
455
|
end
|
460
456
|
end
|
461
|
-
|
462
457
|
class Node_mul < Node
|
463
458
|
attr_accessor :left, :right
|
464
459
|
attr_accessor
|
@@ -477,7 +472,6 @@ class Node_mul < Node
|
|
477
472
|
self
|
478
473
|
end
|
479
474
|
end
|
480
|
-
|
481
475
|
class Node_div < Node
|
482
476
|
attr_accessor :left, :right
|
483
477
|
attr_accessor
|
@@ -496,7 +490,6 @@ class Node_div < Node
|
|
496
490
|
self
|
497
491
|
end
|
498
492
|
end
|
499
|
-
|
500
493
|
class Node_literal < Node
|
501
494
|
attr_accessor :n
|
502
495
|
attr_accessor :n
|
@@ -520,12 +513,12 @@ end
|
|
520
513
|
node.accept(self)
|
521
514
|
end
|
522
515
|
|
523
|
-
module_eval <<-'.,.,
|
516
|
+
module_eval <<-'.,.,122745803836640.,.,', 'sample_calc/calc.ast.action.dr', 19
|
524
517
|
|
525
518
|
|
526
|
-
.,.,
|
519
|
+
.,.,122745803836640.,.,
|
527
520
|
|
528
|
-
module_eval <<-'.,.,
|
521
|
+
module_eval <<-'.,.,122745803860945.,.,', 'sample_calc/calc.ast.action.dr', 19
|
529
522
|
def visit_Node_add node
|
530
523
|
node.value = visit(node.left).value + visit(node.right).value
|
531
524
|
|
@@ -534,9 +527,9 @@ def visit_Node_add node
|
|
534
527
|
raise
|
535
528
|
|
536
529
|
end
|
537
|
-
.,.,
|
530
|
+
.,.,122745803860945.,.,
|
538
531
|
|
539
|
-
module_eval <<-'.,.,
|
532
|
+
module_eval <<-'.,.,122745803823377.,.,', 'sample_calc/calc.ast.action.dr', 20
|
540
533
|
def visit_Node_sub node
|
541
534
|
node.value = visit(node.left).value - visit(node.right).value
|
542
535
|
|
@@ -545,9 +538,9 @@ def visit_Node_sub node
|
|
545
538
|
raise
|
546
539
|
|
547
540
|
end
|
548
|
-
.,.,
|
541
|
+
.,.,122745803823377.,.,
|
549
542
|
|
550
|
-
module_eval <<-'.,.,
|
543
|
+
module_eval <<-'.,.,12274580385321.,.,', 'sample_calc/calc.ast.action.dr', 21
|
551
544
|
def visit_Node_mul node
|
552
545
|
node.value = visit(node.left).value * visit(node.right).value
|
553
546
|
|
@@ -556,9 +549,9 @@ def visit_Node_mul node
|
|
556
549
|
raise
|
557
550
|
|
558
551
|
end
|
559
|
-
.,.,
|
552
|
+
.,.,12274580385321.,.,
|
560
553
|
|
561
|
-
module_eval <<-'.,.,
|
554
|
+
module_eval <<-'.,.,12274580389451.,.,', 'sample_calc/calc.ast.action.dr', 22
|
562
555
|
def visit_Node_div node
|
563
556
|
node.value = visit(node.left).value / visit(node.right).value
|
564
557
|
|
@@ -567,9 +560,9 @@ def visit_Node_div node
|
|
567
560
|
raise
|
568
561
|
|
569
562
|
end
|
570
|
-
.,.,
|
563
|
+
.,.,12274580389451.,.,
|
571
564
|
|
572
|
-
module_eval <<-'.,.,
|
565
|
+
module_eval <<-'.,.,122745803835690.,.,', 'sample_calc/calc.ast.action.dr', 23
|
573
566
|
def visit_Node_literal node
|
574
567
|
node.value = node.n.value
|
575
568
|
|
@@ -578,13 +571,13 @@ def visit_Node_literal node
|
|
578
571
|
raise
|
579
572
|
|
580
573
|
end
|
581
|
-
.,.,
|
574
|
+
.,.,122745803835690.,.,
|
582
575
|
|
583
576
|
end
|
584
577
|
|
585
578
|
class D4TinyCalc::ASTBuilder < Depager::LALR::Action #:nodoc:all
|
586
579
|
include Depager::DecoratorUtils
|
587
|
-
|
580
|
+
|
588
581
|
on_reduce = [
|
589
582
|
nil,
|
590
583
|
:_ast_0,
|
@@ -605,59 +598,60 @@ class D4TinyCalc::ASTBuilder < Depager::LALR::Action #:nodoc:all
|
|
605
598
|
end
|
606
599
|
|
607
600
|
|
608
|
-
module_eval <<-'.,.,
|
601
|
+
module_eval <<-'.,.,122745803840943.,.,', 'sample_calc/calc.ast.action.dr', 29
|
609
602
|
def _ast_0 val
|
610
603
|
Node_add.new(val[0].lineno, val[0], val[2])
|
611
604
|
end
|
612
|
-
.,.,
|
605
|
+
.,.,122745803840943.,.,
|
613
606
|
|
614
|
-
module_eval <<-'.,.,
|
607
|
+
module_eval <<-'.,.,122745803849112.,.,', 'sample_calc/calc.ast.action.dr', 32
|
615
608
|
def _ast_1 val
|
616
609
|
Node_sub.new(val[0].lineno, val[0], val[2])
|
617
610
|
end
|
618
|
-
.,.,
|
611
|
+
.,.,122745803849112.,.,
|
619
612
|
|
620
|
-
module_eval <<-'.,.,
|
613
|
+
module_eval <<-'.,.,122745803812666.,.,', 'sample_calc/calc.ast.action.dr', 35
|
621
614
|
def _ast_2 val
|
622
615
|
val[0]
|
623
616
|
end
|
624
|
-
.,.,
|
617
|
+
.,.,122745803812666.,.,
|
625
618
|
|
626
|
-
module_eval <<-'.,.,
|
619
|
+
module_eval <<-'.,.,122745803828835.,.,', 'sample_calc/calc.ast.action.dr', 40
|
627
620
|
def _ast_3 val
|
628
621
|
Node_mul.new(val[0].lineno, val[0], val[2])
|
629
622
|
end
|
630
|
-
.,.,
|
623
|
+
.,.,122745803828835.,.,
|
631
624
|
|
632
|
-
module_eval <<-'.,.,
|
625
|
+
module_eval <<-'.,.,122745803856208.,.,', 'sample_calc/calc.ast.action.dr', 43
|
633
626
|
def _ast_4 val
|
634
627
|
Node_div.new(val[0].lineno, val[0], val[2])
|
635
628
|
end
|
636
|
-
.,.,
|
629
|
+
.,.,122745803856208.,.,
|
637
630
|
|
638
|
-
module_eval <<-'.,.,
|
631
|
+
module_eval <<-'.,.,122745803842081.,.,', 'sample_calc/calc.ast.action.dr', 46
|
639
632
|
def _ast_5 val
|
640
633
|
val[0]
|
641
634
|
end
|
642
|
-
.,.,
|
635
|
+
.,.,122745803842081.,.,
|
643
636
|
|
644
|
-
module_eval <<-'.,.,
|
637
|
+
module_eval <<-'.,.,122745803820842.,.,', 'sample_calc/calc.ast.action.dr', 51
|
645
638
|
def _ast_6 val
|
646
639
|
Node_literal.new(val[0].lineno, val[0])
|
647
640
|
end
|
648
|
-
.,.,
|
641
|
+
.,.,122745803820842.,.,
|
649
642
|
|
650
|
-
module_eval <<-'.,.,
|
643
|
+
module_eval <<-'.,.,122745803861388.,.,', 'sample_calc/calc.ast.action.dr', 54
|
651
644
|
def _ast_7 val
|
652
645
|
val[1]
|
653
646
|
end
|
654
|
-
.,.,
|
647
|
+
.,.,122745803861388.,.,
|
655
648
|
|
656
649
|
end
|
657
650
|
|
658
651
|
class D4TinyCalc::Action < Depager::LALR::Action #:nodoc:all
|
659
652
|
include Depager::DecoratorUtils
|
660
|
-
|
653
|
+
include Depager
|
654
|
+
|
661
655
|
on_reduce = [
|
662
656
|
nil,
|
663
657
|
:_act_0,
|
@@ -678,61 +672,61 @@ class D4TinyCalc::Action < Depager::LALR::Action #:nodoc:all
|
|
678
672
|
end
|
679
673
|
|
680
674
|
|
681
|
-
module_eval <<-'.,.,
|
675
|
+
module_eval <<-'.,.,122745803844148.,.,', 'sample_calc/calc.ast.action.dr', 30
|
682
676
|
def _act_0 val
|
683
677
|
val[0] + val[2]
|
684
678
|
|
685
679
|
end
|
686
|
-
.,.,
|
680
|
+
.,.,122745803844148.,.,
|
687
681
|
|
688
|
-
module_eval <<-'.,.,
|
682
|
+
module_eval <<-'.,.,122745803845543.,.,', 'sample_calc/calc.ast.action.dr', 33
|
689
683
|
def _act_1 val
|
690
684
|
val[0] - val[2]
|
691
685
|
|
692
686
|
end
|
693
|
-
.,.,
|
687
|
+
.,.,122745803845543.,.,
|
694
688
|
|
695
|
-
module_eval <<-'.,.,
|
689
|
+
module_eval <<-'.,.,122745803827764.,.,', 'sample_calc/calc.ast.action.dr', 36
|
696
690
|
def _act_2 val
|
697
691
|
val[0]
|
698
692
|
|
699
693
|
end
|
700
|
-
.,.,
|
694
|
+
.,.,122745803827764.,.,
|
701
695
|
|
702
|
-
module_eval <<-'.,.,
|
696
|
+
module_eval <<-'.,.,122745803817369.,.,', 'sample_calc/calc.ast.action.dr', 41
|
703
697
|
def _act_3 val
|
704
698
|
val[0] * val[2]
|
705
699
|
|
706
700
|
end
|
707
|
-
.,.,
|
701
|
+
.,.,122745803817369.,.,
|
708
702
|
|
709
|
-
module_eval <<-'.,.,
|
703
|
+
module_eval <<-'.,.,122745803812.,.,', 'sample_calc/calc.ast.action.dr', 44
|
710
704
|
def _act_4 val
|
711
705
|
val[0] / val[2]
|
712
706
|
|
713
707
|
end
|
714
|
-
.,.,
|
708
|
+
.,.,122745803812.,.,
|
715
709
|
|
716
|
-
module_eval <<-'.,.,
|
710
|
+
module_eval <<-'.,.,122745803822872.,.,', 'sample_calc/calc.ast.action.dr', 47
|
717
711
|
def _act_5 val
|
718
712
|
val[0]
|
719
713
|
|
720
714
|
end
|
721
|
-
.,.,
|
715
|
+
.,.,122745803822872.,.,
|
722
716
|
|
723
|
-
module_eval <<-'.,.,
|
717
|
+
module_eval <<-'.,.,12274580385526.,.,', 'sample_calc/calc.ast.action.dr', 52
|
724
718
|
def _act_6 val
|
725
719
|
val[0].value
|
726
720
|
|
727
721
|
end
|
728
|
-
.,.,
|
722
|
+
.,.,12274580385526.,.,
|
729
723
|
|
730
|
-
module_eval <<-'.,.,
|
724
|
+
module_eval <<-'.,.,122745803860083.,.,', 'sample_calc/calc.ast.action.dr', 55
|
731
725
|
def _act_7 val
|
732
726
|
val[1].value
|
733
727
|
|
734
728
|
end
|
735
|
-
.,.,
|
729
|
+
.,.,122745803860083.,.,
|
736
730
|
|
737
731
|
end
|
738
732
|
|
@@ -746,7 +740,7 @@ if __FILE__ == $0
|
|
746
740
|
### Main Code
|
747
741
|
require 'pp'
|
748
742
|
parser = createDecoratedTinyCalc()
|
749
|
-
t, r = parser.
|
743
|
+
t, r = parser.parse(STDIN)
|
750
744
|
v = Visitor.new
|
751
745
|
pp r
|
752
746
|
pp t.accept(v).value
|