depager 0.2.2 → 0.2.3

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.
Files changed (62) hide show
  1. data/ChangeLog +4 -0
  2. data/README.ja +27 -28
  3. data/examples/c89/c89.dr +34 -34
  4. data/examples/c89/c89.tab.rb +3074 -3074
  5. data/examples/extension/paction.dr +4 -4
  6. data/examples/extension/pactiontest.dr +1 -1
  7. data/examples/pl0d/pl0ds.dr +27 -27
  8. data/examples/pl0d/pl0ds.tab.rb +626 -643
  9. data/examples/sample_calc/calc.action.dr +6 -6
  10. data/examples/sample_calc/calc.action.tab.rb +90 -90
  11. data/examples/sample_calc/calc.ast.action.dr +7 -7
  12. data/examples/sample_calc/calc.ast.action.tab.rb +121 -127
  13. data/examples/sample_calc/calc.ast.dr +6 -6
  14. data/examples/sample_calc/calc.ast.tab.rb +102 -109
  15. data/examples/sample_calc/calc.astdf.dr +6 -6
  16. data/examples/sample_calc/calc.astdf.tab.rb +102 -109
  17. data/examples/sample_calc/calc.atree.dr +6 -6
  18. data/examples/sample_calc/calc.atree.tab.rb +90 -90
  19. data/examples/sample_calc/calc.cst.dr +5 -5
  20. data/examples/sample_calc/calc.cst.tab.rb +106 -106
  21. data/examples/sample_calc/calc.dr +1 -1
  22. data/examples/sample_calc/calc.lex.dr +4 -4
  23. data/examples/sample_calc/calc.lex.tab.rb +73 -73
  24. data/examples/sample_calc/calc.nvaction.dr +6 -6
  25. data/examples/sample_calc/calc.nvaction.tab.rb +90 -90
  26. data/examples/sample_calc/calc.tab.rb +71 -71
  27. data/examples/sample_calc/calc_prec.nvaction.dr +6 -6
  28. data/examples/sample_calc/calc_prec.nvaction.tab.rb +46 -46
  29. data/examples/slex_test/divreg.slex.dr +7 -7
  30. data/examples/slex_test/divreg.slex.tab.rb +20 -20
  31. data/examples/slex_test/ljoin.slex.dr +7 -7
  32. data/examples/slex_test/ljoin.slex.tab.rb +15 -15
  33. data/lib/depager.rb +45 -83
  34. data/lib/depager/grammar.rb +3 -7
  35. data/lib/depager/lr.rb +123 -1
  36. data/lib/depager/parser.rb +29 -48
  37. data/lib/depager/{template/ast.erbs → ruby/plugins/_ast_tmpl.rb} +11 -7
  38. data/lib/depager/{action.rb → ruby/plugins/action.rb} +7 -11
  39. data/lib/depager/{ast.dr → ruby/plugins/ast.dr} +24 -25
  40. data/lib/depager/{ast.rb → ruby/plugins/ast.rb} +241 -243
  41. data/lib/depager/{astdf.rb → ruby/plugins/astdf.rb} +1 -2
  42. data/lib/depager/{atree.dr → ruby/plugins/atree.dr} +5 -5
  43. data/lib/depager/{atree.rb → ruby/plugins/atree.rb} +39 -39
  44. data/lib/depager/{cst.dr → ruby/plugins/cst.dr} +17 -21
  45. data/lib/depager/{cst.rb → ruby/plugins/cst.rb} +62 -68
  46. data/lib/depager/{lex.dr → ruby/plugins/lex.dr} +3 -4
  47. data/lib/depager/{lex.rb → ruby/plugins/lex.rb} +29 -31
  48. data/lib/depager/{nvaction.rb → ruby/plugins/nvaction.rb} +1 -3
  49. data/lib/depager/{slex.dr → ruby/plugins/slex.dr} +16 -17
  50. data/lib/depager/{slex.rb → ruby/plugins/slex.rb} +115 -117
  51. data/lib/depager/{srp.rb → ruby/plugins/srp.rb} +4 -4
  52. data/lib/depager/{template → ruby/templates}/extension_lalr_master.erb +6 -6
  53. data/lib/depager/{template → ruby/templates}/extension_lalr_slave.erb +0 -0
  54. data/lib/depager/{template → ruby/templates}/simple.erb +0 -0
  55. data/lib/depager/{template → ruby/templates}/single_lalr_parser.erb +0 -0
  56. data/lib/depager/utils.rb +30 -69
  57. data/lib/depager/version.rb +1 -1
  58. metadata +59 -56
  59. data/examples/Rakefile +0 -36
  60. data/lib/depager/Rakefile +0 -34
  61. data/lib/depager/lr_put_table.rb +0 -116
  62. data/lib/depager/parse_action.rb +0 -24
@@ -40,4 +40,4 @@
40
40
  #end-rule
41
41
  %%
42
42
  parser = TinyCalc.new()
43
- parser.yyparse(STDIN)
43
+ parser.parse(STDIN)
@@ -1,11 +1,11 @@
1
1
  %class TinyCalc
2
- %extend Lexer ('depager/lex.rb')
2
+ %extend Lexer ('plugins/lex.rb')
3
3
  %%
4
4
 
5
5
  %LEX{
6
6
  /\s+/, /\#.*/, /\n/ { }
7
- /[1-9][0-9]*/ { yield :NUM, $&.to_i }
8
- /./ { yield $&, $& }
7
+ /[1-9][0-9]*/ { yield token(:NUM, $&.to_i) }
8
+ /./ { yield token($&, $&) }
9
9
  %}
10
10
 
11
11
  #begin-rule
@@ -26,4 +26,4 @@
26
26
  #end-rule
27
27
  %%
28
28
  parser = TinyCalc.new()
29
- parser.yyparse(STDIN)
29
+ parser.parse(STDIN)
@@ -50,25 +50,26 @@ class TinyCalc < Depager::LALR::Basis
50
50
  ]
51
51
  ### Action Table
52
52
  action_table = [
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, ],
53
+ [ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
54
+ [ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
55
+ [ ACC, nil, 7, 8, nil, nil, nil, nil, nil, ],
56
+ [ nil, nil, nil, nil, 9, 10, nil, nil, nil, ],
56
57
  [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
57
58
  [ nil, nil, nil, 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, ],
59
+ [ nil, nil, 7, 8, nil, nil, nil, nil, 11, ],
60
+ [ nil, nil, nil, nil, nil, nil, 5, 1, nil, ],
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, ],
66
64
  [ 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,
72
73
  nil,
73
74
  nil,
74
75
  -3,
@@ -79,17 +80,17 @@ class TinyCalc < Depager::LALR::Basis
79
80
  nil,
80
81
  nil,
81
82
  nil,
82
- nil,
83
+ -8,
83
84
  -1,
84
85
  -2,
85
86
  -4,
86
87
  -5,
87
- -8,
88
88
  ]
89
89
  defred_after_shift_table = [
90
90
  nil,
91
91
  nil,
92
92
  nil,
93
+ nil,
93
94
  -6,
94
95
  -7,
95
96
  nil,
@@ -97,12 +98,11 @@ class TinyCalc < Depager::LALR::Basis
97
98
  nil,
98
99
  nil,
99
100
  nil,
100
- nil,
101
+ -8,
101
102
  nil,
102
103
  nil,
103
104
  -4,
104
105
  -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
- [ 1, 2, 3, ],
121
+ [ 2, 3, 4, ],
122
+ [ 6, 3, 4, ],
122
123
  [ nil, nil, nil, ],
123
124
  [ nil, nil, nil, ],
124
125
  [ nil, nil, nil, ],
125
126
  [ nil, nil, nil, ],
126
- [ 10, 2, 3, ],
127
- [ nil, 11, 3, ],
128
- [ nil, 12, 3, ],
129
- [ nil, nil, 13, ],
130
- [ nil, nil, 14, ],
131
127
  [ nil, nil, nil, ],
128
+ [ nil, 12, 4, ],
129
+ [ nil, 13, 4, ],
130
+ [ nil, nil, 14, ],
131
+ [ nil, nil, 15, ],
132
132
  [ nil, nil, nil, ],
133
133
  [ nil, nil, nil, ],
134
134
  [ nil, nil, nil, ],
@@ -149,20 +149,30 @@ class TinyCalc < Depager::LALR::Basis
149
149
  I000 =
150
150
  ( 0) $start : _ expr
151
151
 
152
- NUM shift, and goto to state 4
153
- '(' shift, and goto to state 5
152
+ NUM shift, and goto to state 5
153
+ '(' shift, and goto to state 1
154
154
 
155
155
 
156
156
  ----------
157
157
 
158
158
  <<'----------',
159
159
  I001 =
160
+ ( 8) fact : '(' _ expr ')'
161
+
162
+ NUM shift, and goto to state 5
163
+ '(' shift, and goto to state 1
164
+
165
+
166
+ ----------
167
+
168
+ <<'----------',
169
+ I002 =
160
170
  ( 0) $start : expr _
161
171
  ( 1) expr : expr _ '+' term
162
172
  ( 2) expr : expr _ '-' term
163
173
 
164
- '+' shift, and goto to state 6
165
- '-' shift, and goto to state 7
174
+ '+' shift, and goto to state 7
175
+ '-' shift, and goto to state 8
166
176
 
167
177
 
168
178
  $end accept
@@ -170,20 +180,20 @@ I001 =
170
180
  ----------
171
181
 
172
182
  <<'----------',
173
- I002 =
183
+ I003 =
174
184
  ( 3) expr : term _
175
185
  ( 4) term : term _ '*' fact
176
186
  ( 5) term : term _ '/' fact
177
187
 
178
- '*' shift, and goto to state 8
179
- '/' shift, and goto to state 9
188
+ '*' shift, and goto to state 9
189
+ '/' shift, and goto to state 10
180
190
 
181
191
  $default reduce using rule 3 (expr)
182
192
 
183
193
  ----------
184
194
 
185
195
  <<'----------',
186
- I003 =
196
+ I004 =
187
197
  ( 6) term : fact _
188
198
 
189
199
 
@@ -192,7 +202,7 @@ I003 =
192
202
  ----------
193
203
 
194
204
  <<'----------',
195
- I004 =
205
+ I005 =
196
206
  ( 7) fact : NUM _
197
207
 
198
208
 
@@ -201,96 +211,95 @@ I004 =
201
211
  ----------
202
212
 
203
213
  <<'----------',
204
- I005 =
205
- ( 8) fact : '(' _ expr ')'
214
+ I006 =
215
+ ( 8) fact : '(' expr _ ')'
216
+ ( 1) expr : expr _ '+' term
217
+ ( 2) expr : expr _ '-' term
206
218
 
207
- NUM shift, and goto to state 4
208
- '(' shift, and goto to state 5
219
+ '+' shift, and goto to state 7
220
+ '-' shift, and goto to state 8
221
+ ')' shift, and goto to state 11
209
222
 
210
223
 
211
224
  ----------
212
225
 
213
226
  <<'----------',
214
- I006 =
227
+ I007 =
215
228
  ( 1) expr : expr '+' _ term
216
229
 
217
- NUM shift, and goto to state 4
218
- '(' shift, and goto to state 5
230
+ NUM shift, and goto to state 5
231
+ '(' shift, and goto to state 1
219
232
 
220
233
 
221
234
  ----------
222
235
 
223
236
  <<'----------',
224
- I007 =
237
+ I008 =
225
238
  ( 2) expr : expr '-' _ term
226
239
 
227
- NUM shift, and goto to state 4
228
- '(' shift, and goto to state 5
240
+ NUM shift, and goto to state 5
241
+ '(' shift, and goto to state 1
229
242
 
230
243
 
231
244
  ----------
232
245
 
233
246
  <<'----------',
234
- I008 =
247
+ I009 =
235
248
  ( 4) term : term '*' _ fact
236
249
 
237
- NUM shift, and goto to state 4
238
- '(' shift, and goto to state 5
250
+ NUM shift, and goto to state 5
251
+ '(' shift, and goto to state 1
239
252
 
240
253
 
241
254
  ----------
242
255
 
243
256
  <<'----------',
244
- I009 =
257
+ I010 =
245
258
  ( 5) term : term '/' _ fact
246
259
 
247
- NUM shift, and goto to state 4
248
- '(' shift, and goto to state 5
260
+ NUM shift, and goto to state 5
261
+ '(' shift, and goto to state 1
249
262
 
250
263
 
251
264
  ----------
252
265
 
253
266
  <<'----------',
254
- I010 =
255
- ( 8) fact : '(' expr _ ')'
256
- ( 1) expr : expr _ '+' term
257
- ( 2) expr : expr _ '-' term
267
+ I011 =
268
+ ( 8) fact : '(' expr ')' _
258
269
 
259
- '+' shift, and goto to state 6
260
- '-' shift, and goto to state 7
261
- ')' shift, and goto to state 15
262
270
 
271
+ $default reduce using rule 8 (fact) [after shift]
263
272
 
264
273
  ----------
265
274
 
266
275
  <<'----------',
267
- I011 =
276
+ I012 =
268
277
  ( 1) expr : expr '+' term _
269
278
  ( 4) term : term _ '*' fact
270
279
  ( 5) term : term _ '/' fact
271
280
 
272
- '*' shift, and goto to state 8
273
- '/' shift, and goto to state 9
281
+ '*' shift, and goto to state 9
282
+ '/' shift, and goto to state 10
274
283
 
275
284
  $default reduce using rule 1 (expr)
276
285
 
277
286
  ----------
278
287
 
279
288
  <<'----------',
280
- I012 =
289
+ I013 =
281
290
  ( 2) expr : expr '-' term _
282
291
  ( 4) term : term _ '*' fact
283
292
  ( 5) term : term _ '/' fact
284
293
 
285
- '*' shift, and goto to state 8
286
- '/' shift, and goto to state 9
294
+ '*' shift, and goto to state 9
295
+ '/' shift, and goto to state 10
287
296
 
288
297
  $default reduce using rule 2 (expr)
289
298
 
290
299
  ----------
291
300
 
292
301
  <<'----------',
293
- I013 =
302
+ I014 =
294
303
  ( 4) term : term '*' fact _
295
304
 
296
305
 
@@ -299,21 +308,12 @@ I013 =
299
308
  ----------
300
309
 
301
310
  <<'----------',
302
- I014 =
311
+ I015 =
303
312
  ( 5) term : term '/' fact _
304
313
 
305
314
 
306
315
  $default reduce using rule 5 (term) [after shift]
307
316
 
308
- ----------
309
-
310
- <<'----------',
311
- I015 =
312
- ( 8) fact : '(' expr ')' _
313
-
314
-
315
- $default reduce using rule 8 (fact) [after shift]
316
-
317
317
  ----------
318
318
  ]
319
319
 
@@ -340,12 +340,12 @@ I015 =
340
340
 
341
341
  when /\A[1-9][0-9]*/
342
342
  @oldline = @line; @line = $'
343
- yield :NUM, $&.to_i
343
+ yield token(:NUM, $&.to_i)
344
344
 
345
345
 
346
346
  when /\A./
347
347
  @oldline = @line; @line = $'
348
- yield $&, $&
348
+ yield token($&, $&)
349
349
 
350
350
 
351
351
  else
@@ -369,6 +369,6 @@ end
369
369
  if __FILE__ == $0
370
370
  ### Main Code
371
371
  parser = TinyCalc.new()
372
- parser.yyparse(STDIN)
372
+ parser.parse(STDIN)
373
373
 
374
374
  end
@@ -1,14 +1,14 @@
1
1
  %class TinyCalc
2
- %extend Lexer ('depager/lex.rb')
3
- %extend NVAction ('depager/nvaction.rb')
2
+ %extend Lexer ('plugins/lex.rb')
3
+ %extend NVAction ('plugins/nvaction.rb')
4
4
  %decorate @NVAction
5
- #%decorate ShiftReducePrinter ('depager/srp.rb')
5
+ #%decorate ShiftReducePrinter ('plugins/srp.rb')
6
6
  %%
7
7
 
8
8
  %LEX{
9
9
  /\s+/, /\#.*/ { }
10
- /[1-9][0-9]*/ { yield _Token(:NUM, $&.to_i) }
11
- /./ { yield _Token($&, $&) }
10
+ /[1-9][0-9]*/ { yield token(:NUM, $&.to_i) }
11
+ /./ { yield token($&, $&) }
12
12
  %}
13
13
 
14
14
  #begin-rule
@@ -29,5 +29,5 @@
29
29
  #end-rule
30
30
  %%
31
31
  parser = createDecoratedTinyCalc
32
- r, = parser.yyparse(STDIN)
32
+ r, = parser.parse(STDIN)
33
33
  puts r
@@ -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, 4, 5, nil, ],
55
- [ ACC, nil, 6, 7, nil, nil, nil, nil, nil, ],
56
- [ nil, nil, nil, nil, 8, 9, nil, nil, nil, ],
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, 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, ],
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
- nil,
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
- nil,
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
- [ 1, 2, 3, ],
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 4
154
- '(' shift, and goto to state 5
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 6
166
- '-' shift, and goto to state 7
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
- I002 =
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 8
180
- '/' shift, and goto to state 9
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
- I003 =
197
+ I004 =
188
198
  ( 6) term : fact _
189
199
 
190
200
 
@@ -193,7 +203,7 @@ I003 =
193
203
  ----------
194
204
 
195
205
  <<'----------',
196
- I004 =
206
+ I005 =
197
207
  ( 7) fact : NUM _
198
208
 
199
209
 
@@ -202,96 +212,95 @@ I004 =
202
212
  ----------
203
213
 
204
214
  <<'----------',
205
- I005 =
206
- ( 8) fact : '(' _ expr ')'
215
+ I006 =
216
+ ( 8) fact : '(' expr _ ')'
217
+ ( 1) expr : expr _ '+' term
218
+ ( 2) expr : expr _ '-' term
207
219
 
208
- NUM shift, and goto to state 4
209
- '(' shift, and goto to state 5
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
- I006 =
228
+ I007 =
216
229
  ( 1) expr : expr '+' _ term
217
230
 
218
- NUM shift, and goto to state 4
219
- '(' shift, and goto to state 5
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
- I007 =
238
+ I008 =
226
239
  ( 2) expr : expr '-' _ term
227
240
 
228
- NUM shift, and goto to state 4
229
- '(' shift, and goto to state 5
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
- I008 =
248
+ I009 =
236
249
  ( 4) term : term '*' _ fact
237
250
 
238
- NUM shift, and goto to state 4
239
- '(' shift, and goto to state 5
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
- I009 =
258
+ I010 =
246
259
  ( 5) term : term '/' _ fact
247
260
 
248
- NUM shift, and goto to state 4
249
- '(' shift, and goto to state 5
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
- I010 =
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
- I011 =
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 8
274
- '/' shift, and goto to state 9
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
- I012 =
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 8
287
- '/' shift, and goto to state 9
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
- I013 =
303
+ I014 =
295
304
  ( 4) term : term '*' fact _
296
305
 
297
306
 
@@ -300,21 +309,12 @@ I013 =
300
309
  ----------
301
310
 
302
311
  <<'----------',
303
- I014 =
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 _Token(:NUM, $&.to_i)
344
+ yield token(:NUM, $&.to_i)
345
345
 
346
346
 
347
347
  when /\A./
348
348
  @oldline = @line; @line = $'
349
- yield _Token($&, $&)
349
+ yield token($&, $&)
350
350
 
351
351
 
352
352
  else
@@ -363,7 +363,7 @@ end
363
363
 
364
364
  class D4TinyCalc::NVAction < Depager::LALR::Action #:nodoc:all
365
365
  include Depager::DecoratorUtils
366
- []
366
+
367
367
  on_reduce = [
368
368
  nil,
369
369
  :_act_0,
@@ -384,69 +384,69 @@ class D4TinyCalc::NVAction < Depager::LALR::Action #:nodoc:all
384
384
  end
385
385
 
386
386
 
387
- module_eval <<-'.,.,120998293534507.,.,', 'sample_calc/calc.nvaction.dr', 14
387
+ module_eval <<-'.,.,122745803961572.,.,', 'sample_calc/calc.nvaction.dr', 14
388
388
  def _act_0 val
389
389
  _expr, _, _term, = *val
390
390
  _expr + _term
391
391
 
392
392
  end
393
- .,.,120998293534507.,.,
393
+ .,.,122745803961572.,.,
394
394
 
395
- module_eval <<-'.,.,120998293543793.,.,', 'sample_calc/calc.nvaction.dr', 15
395
+ module_eval <<-'.,.,122745803917671.,.,', 'sample_calc/calc.nvaction.dr', 15
396
396
  def _act_1 val
397
397
  _expr, _, _term, = *val
398
398
  _expr - _term
399
399
 
400
400
  end
401
- .,.,120998293543793.,.,
401
+ .,.,122745803917671.,.,
402
402
 
403
- module_eval <<-'.,.,12099829356139.,.,', 'sample_calc/calc.nvaction.dr', 16
403
+ module_eval <<-'.,.,12274580397247.,.,', 'sample_calc/calc.nvaction.dr', 16
404
404
  def _act_2 val
405
405
  _term, = *val
406
406
  _term
407
407
 
408
408
  end
409
- .,.,12099829356139.,.,
409
+ .,.,12274580397247.,.,
410
410
 
411
- module_eval <<-'.,.,120998293556044.,.,', 'sample_calc/calc.nvaction.dr', 19
411
+ module_eval <<-'.,.,122745803926497.,.,', 'sample_calc/calc.nvaction.dr', 19
412
412
  def _act_3 val
413
413
  _term, _, _fact, = *val
414
414
  _term * _fact
415
415
 
416
416
  end
417
- .,.,120998293556044.,.,
417
+ .,.,122745803926497.,.,
418
418
 
419
- module_eval <<-'.,.,120998293536062.,.,', 'sample_calc/calc.nvaction.dr', 20
419
+ module_eval <<-'.,.,122745803919971.,.,', 'sample_calc/calc.nvaction.dr', 20
420
420
  def _act_4 val
421
421
  _term, _, _fact, = *val
422
422
  _term / _fact
423
423
 
424
424
  end
425
- .,.,120998293536062.,.,
425
+ .,.,122745803919971.,.,
426
426
 
427
- module_eval <<-'.,.,12099829353784.,.,', 'sample_calc/calc.nvaction.dr', 21
427
+ module_eval <<-'.,.,122745803920937.,.,', 'sample_calc/calc.nvaction.dr', 21
428
428
  def _act_5 val
429
429
  _fact, = *val
430
430
  _fact
431
431
 
432
432
  end
433
- .,.,12099829353784.,.,
433
+ .,.,122745803920937.,.,
434
434
 
435
- module_eval <<-'.,.,120998293538888.,.,', 'sample_calc/calc.nvaction.dr', 24
435
+ module_eval <<-'.,.,122745803940791.,.,', 'sample_calc/calc.nvaction.dr', 24
436
436
  def _act_6 val
437
437
  _NUM, = *val
438
438
  _NUM.value
439
439
 
440
440
  end
441
- .,.,120998293538888.,.,
441
+ .,.,122745803940791.,.,
442
442
 
443
- module_eval <<-'.,.,120998293537392.,.,', 'sample_calc/calc.nvaction.dr', 25
443
+ module_eval <<-'.,.,122745803911472.,.,', 'sample_calc/calc.nvaction.dr', 25
444
444
  def _act_7 val
445
445
  _, _expr, _, = *val
446
446
  _expr
447
447
 
448
448
  end
449
- .,.,120998293537392.,.,
449
+ .,.,122745803911472.,.,
450
450
 
451
451
  end
452
452
 
@@ -459,7 +459,7 @@ end
459
459
  if __FILE__ == $0
460
460
  ### Main Code
461
461
  parser = createDecoratedTinyCalc
462
- r, = parser.yyparse(STDIN)
462
+ r, = parser.parse(STDIN)
463
463
  puts r
464
464
 
465
465
  end