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
@@ -1,14 +1,14 @@
|
|
1
1
|
%class TinyCalc
|
2
|
-
%extend Lexer ('
|
3
|
-
%extend ASTBuilder ('
|
2
|
+
%extend Lexer ('plugins/lex.rb')
|
3
|
+
%extend ASTBuilder ('plugins/ast.rb')
|
4
4
|
%decorate @ASTBuilder
|
5
|
-
#%decorate ShiftReducePrinter ('
|
5
|
+
#%decorate ShiftReducePrinter ('plugins/srp.rb')
|
6
6
|
%%
|
7
7
|
|
8
8
|
%LEX{
|
9
9
|
/\s+/, /\#.*/ { }
|
10
|
-
/[1-9][0-9]*/ { yield
|
11
|
-
/./ { yield
|
10
|
+
/[1-9][0-9]*/ { yield token(:NUM, $&.to_i) }
|
11
|
+
/./ { yield token($&, $&) }
|
12
12
|
%}
|
13
13
|
|
14
14
|
%AST{
|
@@ -48,7 +48,7 @@
|
|
48
48
|
%%
|
49
49
|
require 'pp'
|
50
50
|
parser = createDecoratedTinyCalc()
|
51
|
-
t, = parser.
|
51
|
+
t, = parser.parse(STDIN)
|
52
52
|
v = Visitor.new
|
53
53
|
pp t.accept(v).value
|
54
54
|
pp t
|
@@ -51,25 +51,26 @@ class TinyCalc < Depager::LALR::Basis
|
|
51
51
|
]
|
52
52
|
### Action Table
|
53
53
|
action_table = [
|
54
|
-
[ nil, nil, nil, nil, nil, nil,
|
55
|
-
[
|
56
|
-
[
|
54
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
55
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
56
|
+
[ ACC, nil, 7, 8, nil, nil, nil, nil, nil, ],
|
57
|
+
[ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
|
57
58
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
58
59
|
[ 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,
|
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, ],
|
60
|
+
[ nil, nil, 7, 8, nil, nil, nil, nil, 11, ],
|
61
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
62
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
63
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
64
|
+
[ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
|
67
65
|
[ 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,
|
73
74
|
nil,
|
74
75
|
nil,
|
75
76
|
-3,
|
@@ -80,17 +81,17 @@ class TinyCalc < Depager::LALR::Basis
|
|
80
81
|
nil,
|
81
82
|
nil,
|
82
83
|
nil,
|
83
|
-
|
84
|
+
-8,
|
84
85
|
-1,
|
85
86
|
-2,
|
86
87
|
-4,
|
87
88
|
-5,
|
88
|
-
-8,
|
89
89
|
]
|
90
90
|
defred_after_shift_table = [
|
91
91
|
nil,
|
92
92
|
nil,
|
93
93
|
nil,
|
94
|
+
nil,
|
94
95
|
-6,
|
95
96
|
-7,
|
96
97
|
nil,
|
@@ -98,12 +99,11 @@ class TinyCalc < Depager::LALR::Basis
|
|
98
99
|
nil,
|
99
100
|
nil,
|
100
101
|
nil,
|
101
|
-
|
102
|
+
-8,
|
102
103
|
nil,
|
103
104
|
nil,
|
104
105
|
-4,
|
105
106
|
-5,
|
106
|
-
-8,
|
107
107
|
]
|
108
108
|
### Nonterm to Int
|
109
109
|
nt2i = {
|
@@ -119,17 +119,17 @@ class TinyCalc < Depager::LALR::Basis
|
|
119
119
|
]
|
120
120
|
### Goto Table
|
121
121
|
goto_table = [
|
122
|
-
[
|
122
|
+
[ 2, 3, 4, ],
|
123
|
+
[ 6, 3, 4, ],
|
123
124
|
[ nil, nil, nil, ],
|
124
125
|
[ nil, nil, nil, ],
|
125
126
|
[ nil, nil, nil, ],
|
126
127
|
[ nil, nil, nil, ],
|
127
|
-
[ 10, 2, 3, ],
|
128
|
-
[ nil, 11, 3, ],
|
129
|
-
[ nil, 12, 3, ],
|
130
|
-
[ nil, nil, 13, ],
|
131
|
-
[ nil, nil, 14, ],
|
132
128
|
[ nil, nil, nil, ],
|
129
|
+
[ nil, 12, 4, ],
|
130
|
+
[ nil, 13, 4, ],
|
131
|
+
[ nil, nil, 14, ],
|
132
|
+
[ nil, nil, 15, ],
|
133
133
|
[ nil, nil, nil, ],
|
134
134
|
[ nil, nil, nil, ],
|
135
135
|
[ nil, nil, nil, ],
|
@@ -150,20 +150,30 @@ class TinyCalc < Depager::LALR::Basis
|
|
150
150
|
I000 =
|
151
151
|
( 0) $start : _ expr
|
152
152
|
|
153
|
-
NUM shift, and goto to state
|
154
|
-
'(' shift, and goto to state
|
153
|
+
NUM shift, and goto to state 5
|
154
|
+
'(' shift, and goto to state 1
|
155
155
|
|
156
156
|
|
157
157
|
----------
|
158
158
|
|
159
159
|
<<'----------',
|
160
160
|
I001 =
|
161
|
+
( 8) fact : '(' _ expr ')'
|
162
|
+
|
163
|
+
NUM shift, and goto to state 5
|
164
|
+
'(' shift, and goto to state 1
|
165
|
+
|
166
|
+
|
167
|
+
----------
|
168
|
+
|
169
|
+
<<'----------',
|
170
|
+
I002 =
|
161
171
|
( 0) $start : expr _
|
162
172
|
( 1) expr : expr _ '+' term
|
163
173
|
( 2) expr : expr _ '-' term
|
164
174
|
|
165
|
-
'+' shift, and goto to state
|
166
|
-
'-' shift, and goto to state
|
175
|
+
'+' shift, and goto to state 7
|
176
|
+
'-' shift, and goto to state 8
|
167
177
|
|
168
178
|
|
169
179
|
$end accept
|
@@ -171,20 +181,20 @@ I001 =
|
|
171
181
|
----------
|
172
182
|
|
173
183
|
<<'----------',
|
174
|
-
|
184
|
+
I003 =
|
175
185
|
( 3) expr : term _
|
176
186
|
( 4) term : term _ '*' fact
|
177
187
|
( 5) term : term _ '/' fact
|
178
188
|
|
179
|
-
'*' shift, and goto to state
|
180
|
-
'/' shift, and goto to state
|
189
|
+
'*' shift, and goto to state 9
|
190
|
+
'/' shift, and goto to state 10
|
181
191
|
|
182
192
|
$default reduce using rule 3 (expr)
|
183
193
|
|
184
194
|
----------
|
185
195
|
|
186
196
|
<<'----------',
|
187
|
-
|
197
|
+
I004 =
|
188
198
|
( 6) term : fact _
|
189
199
|
|
190
200
|
|
@@ -193,7 +203,7 @@ I003 =
|
|
193
203
|
----------
|
194
204
|
|
195
205
|
<<'----------',
|
196
|
-
|
206
|
+
I005 =
|
197
207
|
( 7) fact : NUM _
|
198
208
|
|
199
209
|
|
@@ -202,96 +212,95 @@ I004 =
|
|
202
212
|
----------
|
203
213
|
|
204
214
|
<<'----------',
|
205
|
-
|
206
|
-
( 8) fact : '(' _
|
215
|
+
I006 =
|
216
|
+
( 8) fact : '(' expr _ ')'
|
217
|
+
( 1) expr : expr _ '+' term
|
218
|
+
( 2) expr : expr _ '-' term
|
207
219
|
|
208
|
-
|
209
|
-
'
|
220
|
+
'+' shift, and goto to state 7
|
221
|
+
'-' shift, and goto to state 8
|
222
|
+
')' shift, and goto to state 11
|
210
223
|
|
211
224
|
|
212
225
|
----------
|
213
226
|
|
214
227
|
<<'----------',
|
215
|
-
|
228
|
+
I007 =
|
216
229
|
( 1) expr : expr '+' _ term
|
217
230
|
|
218
|
-
NUM shift, and goto to state
|
219
|
-
'(' shift, and goto to state
|
231
|
+
NUM shift, and goto to state 5
|
232
|
+
'(' shift, and goto to state 1
|
220
233
|
|
221
234
|
|
222
235
|
----------
|
223
236
|
|
224
237
|
<<'----------',
|
225
|
-
|
238
|
+
I008 =
|
226
239
|
( 2) expr : expr '-' _ term
|
227
240
|
|
228
|
-
NUM shift, and goto to state
|
229
|
-
'(' shift, and goto to state
|
241
|
+
NUM shift, and goto to state 5
|
242
|
+
'(' shift, and goto to state 1
|
230
243
|
|
231
244
|
|
232
245
|
----------
|
233
246
|
|
234
247
|
<<'----------',
|
235
|
-
|
248
|
+
I009 =
|
236
249
|
( 4) term : term '*' _ fact
|
237
250
|
|
238
|
-
NUM shift, and goto to state
|
239
|
-
'(' shift, and goto to state
|
251
|
+
NUM shift, and goto to state 5
|
252
|
+
'(' shift, and goto to state 1
|
240
253
|
|
241
254
|
|
242
255
|
----------
|
243
256
|
|
244
257
|
<<'----------',
|
245
|
-
|
258
|
+
I010 =
|
246
259
|
( 5) term : term '/' _ fact
|
247
260
|
|
248
|
-
NUM shift, and goto to state
|
249
|
-
'(' shift, and goto to state
|
261
|
+
NUM shift, and goto to state 5
|
262
|
+
'(' shift, and goto to state 1
|
250
263
|
|
251
264
|
|
252
265
|
----------
|
253
266
|
|
254
267
|
<<'----------',
|
255
|
-
|
256
|
-
( 8) fact : '(' expr
|
257
|
-
( 1) expr : expr _ '+' term
|
258
|
-
( 2) expr : expr _ '-' term
|
268
|
+
I011 =
|
269
|
+
( 8) fact : '(' expr ')' _
|
259
270
|
|
260
|
-
'+' shift, and goto to state 6
|
261
|
-
'-' shift, and goto to state 7
|
262
|
-
')' shift, and goto to state 15
|
263
271
|
|
272
|
+
$default reduce using rule 8 (fact) [after shift]
|
264
273
|
|
265
274
|
----------
|
266
275
|
|
267
276
|
<<'----------',
|
268
|
-
|
277
|
+
I012 =
|
269
278
|
( 1) expr : expr '+' term _
|
270
279
|
( 4) term : term _ '*' fact
|
271
280
|
( 5) term : term _ '/' fact
|
272
281
|
|
273
|
-
'*' shift, and goto to state
|
274
|
-
'/' shift, and goto to state
|
282
|
+
'*' shift, and goto to state 9
|
283
|
+
'/' shift, and goto to state 10
|
275
284
|
|
276
285
|
$default reduce using rule 1 (expr)
|
277
286
|
|
278
287
|
----------
|
279
288
|
|
280
289
|
<<'----------',
|
281
|
-
|
290
|
+
I013 =
|
282
291
|
( 2) expr : expr '-' term _
|
283
292
|
( 4) term : term _ '*' fact
|
284
293
|
( 5) term : term _ '/' fact
|
285
294
|
|
286
|
-
'*' shift, and goto to state
|
287
|
-
'/' shift, and goto to state
|
295
|
+
'*' shift, and goto to state 9
|
296
|
+
'/' shift, and goto to state 10
|
288
297
|
|
289
298
|
$default reduce using rule 2 (expr)
|
290
299
|
|
291
300
|
----------
|
292
301
|
|
293
302
|
<<'----------',
|
294
|
-
|
303
|
+
I014 =
|
295
304
|
( 4) term : term '*' fact _
|
296
305
|
|
297
306
|
|
@@ -300,21 +309,12 @@ I013 =
|
|
300
309
|
----------
|
301
310
|
|
302
311
|
<<'----------',
|
303
|
-
|
312
|
+
I015 =
|
304
313
|
( 5) term : term '/' fact _
|
305
314
|
|
306
315
|
|
307
316
|
$default reduce using rule 5 (term) [after shift]
|
308
317
|
|
309
|
-
----------
|
310
|
-
|
311
|
-
<<'----------',
|
312
|
-
I015 =
|
313
|
-
( 8) fact : '(' expr ')' _
|
314
|
-
|
315
|
-
|
316
|
-
$default reduce using rule 8 (fact) [after shift]
|
317
|
-
|
318
318
|
----------
|
319
319
|
]
|
320
320
|
|
@@ -341,12 +341,12 @@ I015 =
|
|
341
341
|
|
342
342
|
when /\A[1-9][0-9]*/
|
343
343
|
@oldline = @line; @line = $'
|
344
|
-
yield
|
344
|
+
yield token(:NUM, $&.to_i)
|
345
345
|
|
346
346
|
|
347
347
|
when /\A./
|
348
348
|
@oldline = @line; @line = $'
|
349
|
-
yield
|
349
|
+
yield token($&, $&)
|
350
350
|
|
351
351
|
|
352
352
|
else
|
@@ -360,7 +360,6 @@ I015 =
|
|
360
360
|
end
|
361
361
|
|
362
362
|
### Outer Code
|
363
|
-
|
364
363
|
class Node
|
365
364
|
attr_accessor :lineno
|
366
365
|
attr_accessor :value
|
@@ -417,8 +416,6 @@ class NilNode
|
|
417
416
|
def accept v
|
418
417
|
end
|
419
418
|
end
|
420
|
-
|
421
|
-
|
422
419
|
class Node_add < Node
|
423
420
|
attr_accessor :left, :right
|
424
421
|
attr_accessor
|
@@ -437,7 +434,6 @@ class Node_add < Node
|
|
437
434
|
self
|
438
435
|
end
|
439
436
|
end
|
440
|
-
|
441
437
|
class Node_sub < Node
|
442
438
|
attr_accessor :left, :right
|
443
439
|
attr_accessor
|
@@ -456,7 +452,6 @@ class Node_sub < Node
|
|
456
452
|
self
|
457
453
|
end
|
458
454
|
end
|
459
|
-
|
460
455
|
class Node_mul < Node
|
461
456
|
attr_accessor :left, :right
|
462
457
|
attr_accessor
|
@@ -475,7 +470,6 @@ class Node_mul < Node
|
|
475
470
|
self
|
476
471
|
end
|
477
472
|
end
|
478
|
-
|
479
473
|
class Node_div < Node
|
480
474
|
attr_accessor :left, :right
|
481
475
|
attr_accessor
|
@@ -494,7 +488,6 @@ class Node_div < Node
|
|
494
488
|
self
|
495
489
|
end
|
496
490
|
end
|
497
|
-
|
498
491
|
class Node_literal < Node
|
499
492
|
attr_accessor :n
|
500
493
|
attr_accessor :n
|
@@ -518,12 +511,12 @@ end
|
|
518
511
|
node.accept(self)
|
519
512
|
end
|
520
513
|
|
521
|
-
module_eval <<-'.,.,
|
514
|
+
module_eval <<-'.,.,12274580388014.,.,', 'sample_calc/calc.ast.dr', 16
|
522
515
|
|
523
516
|
|
524
|
-
.,.,
|
517
|
+
.,.,12274580388014.,.,
|
525
518
|
|
526
|
-
module_eval <<-'.,.,
|
519
|
+
module_eval <<-'.,.,12274580382340.,.,', 'sample_calc/calc.ast.dr', 16
|
527
520
|
def visit_Node_add node
|
528
521
|
node.value = visit(node.left).value + visit(node.right).value
|
529
522
|
|
@@ -532,9 +525,9 @@ def visit_Node_add node
|
|
532
525
|
raise
|
533
526
|
|
534
527
|
end
|
535
|
-
.,.,
|
528
|
+
.,.,12274580382340.,.,
|
536
529
|
|
537
|
-
module_eval <<-'.,.,
|
530
|
+
module_eval <<-'.,.,122745803847018.,.,', 'sample_calc/calc.ast.dr', 17
|
538
531
|
def visit_Node_sub node
|
539
532
|
node.value = visit(node.left).value - visit(node.right).value
|
540
533
|
|
@@ -543,9 +536,9 @@ def visit_Node_sub node
|
|
543
536
|
raise
|
544
537
|
|
545
538
|
end
|
546
|
-
.,.,
|
539
|
+
.,.,122745803847018.,.,
|
547
540
|
|
548
|
-
module_eval <<-'.,.,
|
541
|
+
module_eval <<-'.,.,122745803816277.,.,', 'sample_calc/calc.ast.dr', 18
|
549
542
|
def visit_Node_mul node
|
550
543
|
node.value = visit(node.left).value * visit(node.right).value
|
551
544
|
|
@@ -554,9 +547,9 @@ def visit_Node_mul node
|
|
554
547
|
raise
|
555
548
|
|
556
549
|
end
|
557
|
-
.,.,
|
550
|
+
.,.,122745803816277.,.,
|
558
551
|
|
559
|
-
module_eval <<-'.,.,
|
552
|
+
module_eval <<-'.,.,122745803846851.,.,', 'sample_calc/calc.ast.dr', 19
|
560
553
|
def visit_Node_div node
|
561
554
|
node.value = visit(node.left).value / visit(node.right).value
|
562
555
|
|
@@ -565,9 +558,9 @@ def visit_Node_div node
|
|
565
558
|
raise
|
566
559
|
|
567
560
|
end
|
568
|
-
.,.,
|
561
|
+
.,.,122745803846851.,.,
|
569
562
|
|
570
|
-
module_eval <<-'.,.,
|
563
|
+
module_eval <<-'.,.,122745803837279.,.,', 'sample_calc/calc.ast.dr', 20
|
571
564
|
def visit_Node_literal node
|
572
565
|
node.value = node.n.value
|
573
566
|
|
@@ -576,13 +569,13 @@ def visit_Node_literal node
|
|
576
569
|
raise
|
577
570
|
|
578
571
|
end
|
579
|
-
.,.,
|
572
|
+
.,.,122745803837279.,.,
|
580
573
|
|
581
574
|
end
|
582
575
|
|
583
576
|
class D4TinyCalc::ASTBuilder < Depager::LALR::Action #:nodoc:all
|
584
577
|
include Depager::DecoratorUtils
|
585
|
-
|
578
|
+
|
586
579
|
on_reduce = [
|
587
580
|
nil,
|
588
581
|
:_ast_0,
|
@@ -603,53 +596,53 @@ class D4TinyCalc::ASTBuilder < Depager::LALR::Action #:nodoc:all
|
|
603
596
|
end
|
604
597
|
|
605
598
|
|
606
|
-
module_eval <<-'.,.,
|
599
|
+
module_eval <<-'.,.,122745803850456.,.,', 'sample_calc/calc.ast.dr', 26
|
607
600
|
def _ast_0 val
|
608
601
|
Node_add.new(val[0].lineno, val[0], val[2])
|
609
602
|
end
|
610
|
-
.,.,
|
603
|
+
.,.,122745803850456.,.,
|
611
604
|
|
612
|
-
module_eval <<-'.,.,
|
605
|
+
module_eval <<-'.,.,122745803848192.,.,', 'sample_calc/calc.ast.dr', 28
|
613
606
|
def _ast_1 val
|
614
607
|
Node_sub.new(val[0].lineno, val[0], val[2])
|
615
608
|
end
|
616
|
-
.,.,
|
609
|
+
.,.,122745803848192.,.,
|
617
610
|
|
618
|
-
module_eval <<-'.,.,
|
611
|
+
module_eval <<-'.,.,12274580384009.,.,', 'sample_calc/calc.ast.dr', 30
|
619
612
|
def _ast_2 val
|
620
613
|
val[0]
|
621
614
|
end
|
622
|
-
.,.,
|
615
|
+
.,.,12274580384009.,.,
|
623
616
|
|
624
|
-
module_eval <<-'.,.,
|
617
|
+
module_eval <<-'.,.,122745803818805.,.,', 'sample_calc/calc.ast.dr', 34
|
625
618
|
def _ast_3 val
|
626
619
|
Node_mul.new(val[0].lineno, val[0], val[2])
|
627
620
|
end
|
628
|
-
.,.,
|
621
|
+
.,.,122745803818805.,.,
|
629
622
|
|
630
|
-
module_eval <<-'.,.,
|
623
|
+
module_eval <<-'.,.,122745803854413.,.,', 'sample_calc/calc.ast.dr', 36
|
631
624
|
def _ast_4 val
|
632
625
|
Node_div.new(val[0].lineno, val[0], val[2])
|
633
626
|
end
|
634
|
-
.,.,
|
627
|
+
.,.,122745803854413.,.,
|
635
628
|
|
636
|
-
module_eval <<-'.,.,
|
629
|
+
module_eval <<-'.,.,122745803853590.,.,', 'sample_calc/calc.ast.dr', 38
|
637
630
|
def _ast_5 val
|
638
631
|
val[0]
|
639
632
|
end
|
640
|
-
.,.,
|
633
|
+
.,.,122745803853590.,.,
|
641
634
|
|
642
|
-
module_eval <<-'.,.,
|
635
|
+
module_eval <<-'.,.,122745803826205.,.,', 'sample_calc/calc.ast.dr', 42
|
643
636
|
def _ast_6 val
|
644
637
|
Node_literal.new(val[0].lineno, val[0])
|
645
638
|
end
|
646
|
-
.,.,
|
639
|
+
.,.,122745803826205.,.,
|
647
640
|
|
648
|
-
module_eval <<-'.,.,
|
641
|
+
module_eval <<-'.,.,122745803851206.,.,', 'sample_calc/calc.ast.dr', 44
|
649
642
|
def _ast_7 val
|
650
643
|
val[1]
|
651
644
|
end
|
652
|
-
.,.,
|
645
|
+
.,.,122745803851206.,.,
|
653
646
|
|
654
647
|
end
|
655
648
|
|
@@ -663,7 +656,7 @@ if __FILE__ == $0
|
|
663
656
|
### Main Code
|
664
657
|
require 'pp'
|
665
658
|
parser = createDecoratedTinyCalc()
|
666
|
-
t, = parser.
|
659
|
+
t, = parser.parse(STDIN)
|
667
660
|
v = Visitor.new
|
668
661
|
pp t.accept(v).value
|
669
662
|
pp t
|