depager 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/Manifest.txt +52 -0
- data/README.en +64 -0
- data/README.ja +128 -0
- data/bin/depager +47 -0
- data/data/depager/misc/depager-mode.el +209 -0
- data/data/depager/sample/extension/paction.dr +15 -0
- data/data/depager/sample/extension/pactiontest.dr +14 -0
- data/data/depager/sample/pl0d/pl0ds.dr +334 -0
- data/data/depager/sample/pl0d/pl0test.pl0 +34 -0
- data/data/depager/sample/sample_calc/calc.action.dr +33 -0
- data/data/depager/sample/sample_calc/calc.astdf.dr +54 -0
- data/data/depager/sample/sample_calc/calc.astl.action.dr +66 -0
- data/data/depager/sample/sample_calc/calc.astl.dr +55 -0
- data/data/depager/sample/sample_calc/calc.atree.dr +43 -0
- data/data/depager/sample/sample_calc/calc.cst.dr +45 -0
- data/data/depager/sample/sample_calc/calc.dr +43 -0
- data/data/depager/sample/sample_calc/calc.lex.dr +29 -0
- data/data/depager/sample/sample_calc/calc.nvaction.dr +33 -0
- data/data/depager/sample/sample_calc/calc_prec.nvaction.dr +31 -0
- data/data/depager/sample/slex_test/slextest1.dr +37 -0
- data/data/depager/sample/slex_test/slextest2.dr +33 -0
- data/lib/depager.rb +608 -0
- data/lib/depager/Rakefile +30 -0
- data/lib/depager/action.rb +47 -0
- data/lib/depager/ast_base.dr +232 -0
- data/lib/depager/ast_base.rb +1249 -0
- data/lib/depager/astdf.rb +10 -0
- data/lib/depager/astl.rb +14 -0
- data/lib/depager/atree.dr +55 -0
- data/lib/depager/atree.rb +336 -0
- data/lib/depager/cst.dr +182 -0
- data/lib/depager/cst.rb +625 -0
- data/lib/depager/lex.dr +76 -0
- data/lib/depager/lex.rb +306 -0
- data/lib/depager/lr.rb +604 -0
- data/lib/depager/nvaction.rb +21 -0
- data/lib/depager/parse_action.rb +24 -0
- data/lib/depager/parser.rb +248 -0
- data/lib/depager/psrtmpl.rb +33 -0
- data/lib/depager/slex.dr +161 -0
- data/lib/depager/slex.rb +646 -0
- data/lib/depager/srp.rb +50 -0
- data/lib/depager/template/astdf.erbs +57 -0
- data/lib/depager/template/astl.erbs +57 -0
- data/lib/depager/template/extension_lalr_master.erb +51 -0
- data/lib/depager/template/extension_lalr_slave.erb +107 -0
- data/lib/depager/template/simple.erb +21 -0
- data/lib/depager/template/single_lalr_parser.erb +97 -0
- data/lib/depager/utils.rb +355 -0
- data/lib/depager/version.rb +9 -0
- data/setup.rb +1585 -0
- metadata +103 -0
data/lib/depager/cst.rb
ADDED
@@ -0,0 +1,625 @@
|
|
1
|
+
|
2
|
+
###
|
3
|
+
### CSTBuilderExtension - Depager Extension (master)
|
4
|
+
###
|
5
|
+
require 'pp.rb'
|
6
|
+
require 'depager/parser.rb'
|
7
|
+
require 'depager/parse_action'
|
8
|
+
|
9
|
+
|
10
|
+
module D4CSTBuilderExtension #:nodoc:all
|
11
|
+
end
|
12
|
+
|
13
|
+
class CSTBuilderExtension #:nodoc:all
|
14
|
+
include Depager::ExtensionUtils
|
15
|
+
|
16
|
+
include ActionParser
|
17
|
+
attr_accessor :h2p
|
18
|
+
|
19
|
+
def initialize
|
20
|
+
@master = self
|
21
|
+
@hook = []
|
22
|
+
@h2p = {}
|
23
|
+
init_parser
|
24
|
+
end
|
25
|
+
|
26
|
+
def __regext__ p
|
27
|
+
super p, :default, nil
|
28
|
+
|
29
|
+
@hook[0] = CSTBuilderExtension_prerulelist.new(p, @nparam, self)
|
30
|
+
@h2p['prerulelist'] = @hook[0]
|
31
|
+
p.prerulelist.push [@hook[0], :do_parse]
|
32
|
+
|
33
|
+
@hook[1] = CSTBuilderExtension_postlhs.new(p, @nparam, self)
|
34
|
+
@h2p['postlhs'] = @hook[1]
|
35
|
+
p.postlhs.push [@hook[1], :do_parse]
|
36
|
+
|
37
|
+
regext p
|
38
|
+
end
|
39
|
+
|
40
|
+
### Inner Code
|
41
|
+
attr_accessor :optouter, :nodes_code
|
42
|
+
def init_parser
|
43
|
+
super
|
44
|
+
@n = 0
|
45
|
+
@visitor_code = []
|
46
|
+
@nodes_code = []
|
47
|
+
@optouter = []
|
48
|
+
@on_reduce = []
|
49
|
+
end
|
50
|
+
def modify_action_code code
|
51
|
+
code.gsub(/~([a-z_])/, 'node.\1')
|
52
|
+
end
|
53
|
+
def postRhs
|
54
|
+
code = ''
|
55
|
+
lineno = g_parser.lineno
|
56
|
+
if token[0] == '{'
|
57
|
+
@line0, @line = g_parser.line0, g_parser.oldline
|
58
|
+
code = parse_action
|
59
|
+
|
60
|
+
fixline @line
|
61
|
+
gettoken
|
62
|
+
end
|
63
|
+
|
64
|
+
node_name = "#{lhs_name}_#{nrhs}"
|
65
|
+
accept = ""
|
66
|
+
nodes = g_parser.rhs.map do |i|
|
67
|
+
x = g_parser.int_to_sym(i)
|
68
|
+
if x.class == String
|
69
|
+
"tx#{x[0].to_s(16)}"
|
70
|
+
else
|
71
|
+
x = x.to_s
|
72
|
+
accept << "#{x}.accept(v); " if x =~ /\A[a-z_]+\Z/
|
73
|
+
x.downcase
|
74
|
+
end
|
75
|
+
end
|
76
|
+
attrc = nodes.map{|i| ":#{i}" }.join(', ')
|
77
|
+
inic = nodes.map{|i| "@#{i} = #{i}"}.join('; ')
|
78
|
+
@nodes_code << %{
|
79
|
+
class Node_#{node_name} < Node_#{lhs_name}
|
80
|
+
attr_accessor #{attrc}
|
81
|
+
def initialize #{nodes.join(', ')}
|
82
|
+
super()
|
83
|
+
#{inic}
|
84
|
+
end
|
85
|
+
def accept v
|
86
|
+
#{accept}
|
87
|
+
v.visit_Node_#{node_name}(self)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
}; #code
|
91
|
+
|
92
|
+
@visitor_code <<
|
93
|
+
gen_defm_code("visit_Node_#{node_name} node",
|
94
|
+
modify_action_code(code), lineno)
|
95
|
+
|
96
|
+
args = nodes.inject([]){|r, i| r << "val[#{r.size}]"}
|
97
|
+
code = "Node_#{node_name}.new(#{args.join(', ')})"
|
98
|
+
@optouter <<
|
99
|
+
gen_defm_code("_cst_#{nrules} val", code, lineno)
|
100
|
+
|
101
|
+
@on_reduce[nrules] = ":_cst_#{nrules}"
|
102
|
+
end
|
103
|
+
def postRuleList
|
104
|
+
code = unindent %{
|
105
|
+
class Node
|
106
|
+
def accept
|
107
|
+
end
|
108
|
+
end
|
109
|
+
}; #code
|
110
|
+
g_parser.optouter << code
|
111
|
+
|
112
|
+
code = unindent %{
|
113
|
+
class Visitor
|
114
|
+
$$!!@ CST @!!$$
|
115
|
+
end
|
116
|
+
}; #code
|
117
|
+
g_parser.optouter <<
|
118
|
+
code.sub!('$$!!@ CST @!!$$', @visitor_code.to_s) <<
|
119
|
+
unindent(@nodes_code) <<
|
120
|
+
gen_action_decorator_code(target_name, paramkey,
|
121
|
+
@on_reduce, @optouter)
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
125
|
+
|
126
|
+
### Outer Code
|
127
|
+
|
128
|
+
###
|
129
|
+
### CSTBuilderExtension_prerulelist - Part of Depager Extension (slave)
|
130
|
+
###
|
131
|
+
module D4CSTBuilderExtension_prerulelist #:nodoc:all
|
132
|
+
end
|
133
|
+
|
134
|
+
class CSTBuilderExtension_prerulelist < Basis #:nodoc:all
|
135
|
+
include Depager::ExtensionUtils
|
136
|
+
|
137
|
+
include ActionParser
|
138
|
+
|
139
|
+
### Reduce Table
|
140
|
+
reduce_table = [
|
141
|
+
[ -1, 1 ],
|
142
|
+
[ 0, 2 ],
|
143
|
+
[ 1, 0 ],
|
144
|
+
[ 1, 2 ],
|
145
|
+
[ 2, 0 ],
|
146
|
+
[ 2, 2 ],
|
147
|
+
]
|
148
|
+
### Extension Params
|
149
|
+
nparams = {
|
150
|
+
'NVAction' => 2,
|
151
|
+
}
|
152
|
+
### Term to Int
|
153
|
+
t2i = {
|
154
|
+
nil => 0,
|
155
|
+
false => 1,
|
156
|
+
:NODE => 2,
|
157
|
+
:ACTION => 3,
|
158
|
+
:VISITOR => 4,
|
159
|
+
}
|
160
|
+
### Int to Term
|
161
|
+
i2t = [
|
162
|
+
nil,
|
163
|
+
false,
|
164
|
+
:NODE,
|
165
|
+
:ACTION,
|
166
|
+
:VISITOR,
|
167
|
+
]
|
168
|
+
### Action Table
|
169
|
+
action_table = [
|
170
|
+
[ nil, nil, 1, nil, nil, ],
|
171
|
+
[ nil, nil, nil, 4, nil, ],
|
172
|
+
[ ACC, nil, nil, nil, nil, ],
|
173
|
+
[ nil, nil, nil, nil, 5, ],
|
174
|
+
[ nil, nil, nil, nil, nil, ],
|
175
|
+
[ nil, nil, nil, 7, nil, ],
|
176
|
+
[ nil, nil, nil, nil, nil, ],
|
177
|
+
[ nil, nil, nil, nil, nil, ],
|
178
|
+
]
|
179
|
+
### Default Reduce Table
|
180
|
+
defred_table = [
|
181
|
+
-2,
|
182
|
+
nil,
|
183
|
+
nil,
|
184
|
+
-4,
|
185
|
+
-3,
|
186
|
+
nil,
|
187
|
+
-1,
|
188
|
+
-5,
|
189
|
+
]
|
190
|
+
defred_after_shift_table = [
|
191
|
+
nil,
|
192
|
+
nil,
|
193
|
+
nil,
|
194
|
+
nil,
|
195
|
+
-3,
|
196
|
+
nil,
|
197
|
+
-1,
|
198
|
+
-5,
|
199
|
+
]
|
200
|
+
### Nonterm to Int
|
201
|
+
nt2i = {
|
202
|
+
:start => 0,
|
203
|
+
:opt_node => 1,
|
204
|
+
:opt_visitor => 2,
|
205
|
+
}
|
206
|
+
### Int to Nonterm
|
207
|
+
i2nt = [
|
208
|
+
:start,
|
209
|
+
:opt_node,
|
210
|
+
:opt_visitor,
|
211
|
+
]
|
212
|
+
### Goto Table
|
213
|
+
goto_table = [
|
214
|
+
[ 2, 3, nil, ],
|
215
|
+
[ nil, nil, nil, ],
|
216
|
+
[ nil, nil, nil, ],
|
217
|
+
[ nil, nil, 6, ],
|
218
|
+
[ nil, nil, nil, ],
|
219
|
+
[ nil, nil, nil, ],
|
220
|
+
[ nil, nil, nil, ],
|
221
|
+
[ nil, nil, nil, ],
|
222
|
+
]
|
223
|
+
|
224
|
+
Tables = [ reduce_table, nparams, action_table,
|
225
|
+
defred_table, defred_after_shift_table, goto_table,
|
226
|
+
t2i, i2t, nt2i, i2nt ]
|
227
|
+
|
228
|
+
attr_accessor :p, :m
|
229
|
+
def initialize p, nparam, master = nil
|
230
|
+
super()
|
231
|
+
@g_parser = @p = p
|
232
|
+
@master = @m = master
|
233
|
+
@nparam = nparam
|
234
|
+
@dect = D4CSTBuilderExtension_prerulelist::NVAction.new(self)
|
235
|
+
init_parser
|
236
|
+
end
|
237
|
+
|
238
|
+
|
239
|
+
def do_parse?
|
240
|
+
if @line =~ /^\s*%CST\{\s*\Z/
|
241
|
+
@line = $'
|
242
|
+
true
|
243
|
+
else
|
244
|
+
false
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
|
249
|
+
def banner
|
250
|
+
"%CST{ ... } / #{@master.class.name}"
|
251
|
+
end
|
252
|
+
|
253
|
+
### Inner Code
|
254
|
+
|
255
|
+
def lex
|
256
|
+
begin
|
257
|
+
until @line.empty? do
|
258
|
+
case @line
|
259
|
+
when /\A\s+/, /\A#.*/
|
260
|
+
|
261
|
+
when /\A%\}\s*\Z/
|
262
|
+
@line = $'; yield nil,nil
|
263
|
+
when /\ANode/
|
264
|
+
yield _Token(:NODE, $&)
|
265
|
+
when /\A\{/
|
266
|
+
ln = lineno; yield _Token(:ACTION, parse_action, ln); //=~''
|
267
|
+
|
268
|
+
else
|
269
|
+
raise RuntimeError, "must not happen #{@line}"
|
270
|
+
end
|
271
|
+
@oldline = @line
|
272
|
+
@line = $'
|
273
|
+
end
|
274
|
+
end while @line = getline
|
275
|
+
yield nil, nil
|
276
|
+
end
|
277
|
+
|
278
|
+
end
|
279
|
+
|
280
|
+
### Outer Code
|
281
|
+
|
282
|
+
class D4CSTBuilderExtension_prerulelist::NVAction < Depager::Action #:nodoc:all
|
283
|
+
include Depager::DecoratorUtils
|
284
|
+
include ActionParser
|
285
|
+
include ActionParser
|
286
|
+
|
287
|
+
on_reduce = [
|
288
|
+
nil,
|
289
|
+
:_act_0,
|
290
|
+
:_act_1,
|
291
|
+
:_act_2,
|
292
|
+
:_act_3,
|
293
|
+
:_act_4,
|
294
|
+
|
295
|
+
]
|
296
|
+
Tables = [on_reduce]
|
297
|
+
def initialize inside
|
298
|
+
super inside, 'NVAction'
|
299
|
+
@on_reduce, = self.class::Tables
|
300
|
+
init_parser
|
301
|
+
end
|
302
|
+
|
303
|
+
|
304
|
+
module_eval <<-'.,.,118028145930197.,.,', 'cst.dr', 104
|
305
|
+
def _act_0 val
|
306
|
+
_opt_node, _opt_visitor = *val
|
307
|
+
|
308
|
+
code = %{
|
309
|
+
class Node
|
310
|
+
$$!!@ NODE @!!$$
|
311
|
+
end
|
312
|
+
class Visitor
|
313
|
+
$$!!@ VISITOR @!!$$
|
314
|
+
end
|
315
|
+
}; #code
|
316
|
+
master.nodes_code <<
|
317
|
+
code.sub!('$$!!@ NODE @!!$$', _opt_node) \
|
318
|
+
.sub!('$$!!@ VISITOR @!!$$', _opt_visitor)
|
319
|
+
|
320
|
+
end
|
321
|
+
|
322
|
+
.,.,118028145930197.,.,
|
323
|
+
|
324
|
+
module_eval <<-'.,.,11802814596438.,.,', 'cst.dr', 118
|
325
|
+
def _act_1 val
|
326
|
+
''
|
327
|
+
|
328
|
+
end
|
329
|
+
|
330
|
+
.,.,11802814596438.,.,
|
331
|
+
|
332
|
+
module_eval <<-'.,.,118028145919370.,.,', 'cst.dr', 119
|
333
|
+
def _act_2 val
|
334
|
+
_NODE, _ACTION = *val
|
335
|
+
_ACTION.value
|
336
|
+
|
337
|
+
end
|
338
|
+
|
339
|
+
.,.,118028145919370.,.,
|
340
|
+
|
341
|
+
module_eval <<-'.,.,118028145927531.,.,', 'cst.dr', 121
|
342
|
+
def _act_3 val
|
343
|
+
warn "VIS";''
|
344
|
+
|
345
|
+
end
|
346
|
+
|
347
|
+
.,.,118028145927531.,.,
|
348
|
+
|
349
|
+
module_eval <<-'.,.,118028145925004.,.,', 'cst.dr', 122
|
350
|
+
def _act_4 val
|
351
|
+
_VISITOR, _ACTION = *val
|
352
|
+
_ACTION.value
|
353
|
+
|
354
|
+
end
|
355
|
+
|
356
|
+
.,.,118028145925004.,.,
|
357
|
+
|
358
|
+
end
|
359
|
+
|
360
|
+
|
361
|
+
###
|
362
|
+
### CSTBuilderExtension_postlhs - Part of Depager Extension (slave)
|
363
|
+
###
|
364
|
+
module D4CSTBuilderExtension_postlhs #:nodoc:all
|
365
|
+
end
|
366
|
+
|
367
|
+
class CSTBuilderExtension_postlhs < Basis #:nodoc:all
|
368
|
+
include Depager::ExtensionUtils
|
369
|
+
|
370
|
+
include ActionParser
|
371
|
+
|
372
|
+
### Reduce Table
|
373
|
+
reduce_table = [
|
374
|
+
[ -1, 1 ],
|
375
|
+
[ 0, 3 ],
|
376
|
+
[ 1, 1 ],
|
377
|
+
[ 1, 3 ],
|
378
|
+
[ 2, 1 ],
|
379
|
+
[ 2, 3 ],
|
380
|
+
]
|
381
|
+
### Extension Params
|
382
|
+
nparams = {
|
383
|
+
'NVAction' => 2,
|
384
|
+
}
|
385
|
+
### Term to Int
|
386
|
+
t2i = {
|
387
|
+
nil => 0,
|
388
|
+
false => 1,
|
389
|
+
"[" => 2,
|
390
|
+
"]" => 3,
|
391
|
+
"," => 4,
|
392
|
+
:ID => 5,
|
393
|
+
"=" => 6,
|
394
|
+
:LIT => 7,
|
395
|
+
}
|
396
|
+
### Int to Term
|
397
|
+
i2t = [
|
398
|
+
nil,
|
399
|
+
false,
|
400
|
+
"[",
|
401
|
+
"]",
|
402
|
+
",",
|
403
|
+
:ID,
|
404
|
+
"=",
|
405
|
+
:LIT,
|
406
|
+
]
|
407
|
+
### Action Table
|
408
|
+
action_table = [
|
409
|
+
[ nil, nil, 1, nil, nil, nil, nil, nil, ],
|
410
|
+
[ nil, nil, nil, nil, nil, 5, nil, nil, ],
|
411
|
+
[ ACC, nil, nil, nil, nil, nil, nil, nil, ],
|
412
|
+
[ nil, nil, nil, 6, 7, nil, nil, nil, ],
|
413
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, ],
|
414
|
+
[ nil, nil, nil, nil, nil, nil, 8, nil, ],
|
415
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, ],
|
416
|
+
[ nil, nil, nil, nil, nil, 5, nil, nil, ],
|
417
|
+
[ nil, nil, nil, nil, nil, nil, nil, 10, ],
|
418
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, ],
|
419
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, ],
|
420
|
+
]
|
421
|
+
### Default Reduce Table
|
422
|
+
defred_table = [
|
423
|
+
nil,
|
424
|
+
nil,
|
425
|
+
nil,
|
426
|
+
nil,
|
427
|
+
-2,
|
428
|
+
-4,
|
429
|
+
-1,
|
430
|
+
nil,
|
431
|
+
nil,
|
432
|
+
-3,
|
433
|
+
-5,
|
434
|
+
]
|
435
|
+
defred_after_shift_table = [
|
436
|
+
nil,
|
437
|
+
nil,
|
438
|
+
nil,
|
439
|
+
nil,
|
440
|
+
-2,
|
441
|
+
nil,
|
442
|
+
-1,
|
443
|
+
nil,
|
444
|
+
nil,
|
445
|
+
-3,
|
446
|
+
-5,
|
447
|
+
]
|
448
|
+
### Nonterm to Int
|
449
|
+
nt2i = {
|
450
|
+
:start => 0,
|
451
|
+
:pair => 1,
|
452
|
+
:expr => 2,
|
453
|
+
}
|
454
|
+
### Int to Nonterm
|
455
|
+
i2nt = [
|
456
|
+
:start,
|
457
|
+
:pair,
|
458
|
+
:expr,
|
459
|
+
]
|
460
|
+
### Goto Table
|
461
|
+
goto_table = [
|
462
|
+
[ 2, nil, nil, ],
|
463
|
+
[ nil, 3, 4, ],
|
464
|
+
[ nil, nil, nil, ],
|
465
|
+
[ nil, nil, nil, ],
|
466
|
+
[ nil, nil, nil, ],
|
467
|
+
[ nil, nil, nil, ],
|
468
|
+
[ nil, nil, nil, ],
|
469
|
+
[ nil, nil, 9, ],
|
470
|
+
[ nil, nil, nil, ],
|
471
|
+
[ nil, nil, nil, ],
|
472
|
+
[ nil, nil, nil, ],
|
473
|
+
]
|
474
|
+
|
475
|
+
Tables = [ reduce_table, nparams, action_table,
|
476
|
+
defred_table, defred_after_shift_table, goto_table,
|
477
|
+
t2i, i2t, nt2i, i2nt ]
|
478
|
+
|
479
|
+
attr_accessor :p, :m
|
480
|
+
def initialize p, nparam, master = nil
|
481
|
+
super()
|
482
|
+
@g_parser = @p = p
|
483
|
+
@master = @m = master
|
484
|
+
@nparam = nparam
|
485
|
+
@dect = D4CSTBuilderExtension_postlhs::NVAction.new(self)
|
486
|
+
init_parser
|
487
|
+
end
|
488
|
+
|
489
|
+
|
490
|
+
def do_parse?
|
491
|
+
if @line =~ /^\s*\[/
|
492
|
+
@line = $'
|
493
|
+
true
|
494
|
+
else
|
495
|
+
false
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
|
500
|
+
def banner
|
501
|
+
"[ ... ] / #{@master.class.name}"
|
502
|
+
end
|
503
|
+
|
504
|
+
### Inner Code
|
505
|
+
|
506
|
+
def lex
|
507
|
+
begin
|
508
|
+
until @line.empty? do
|
509
|
+
case @line
|
510
|
+
when /\A\A\s+/
|
511
|
+
|
512
|
+
when /\A""/, /\A''/, /\A[0-9]+/, /\A\{\s*\}/, /\A\[\s*\]/, /\Anil/
|
513
|
+
yield _Token(:LIT, $&)
|
514
|
+
when /\A\A[a-z][a-z_]*/
|
515
|
+
yield _Token(:ID, $&)
|
516
|
+
when /\A\A(.)/
|
517
|
+
yield _Token($&, $&)
|
518
|
+
|
519
|
+
else
|
520
|
+
raise RuntimeError, "must not happen #{@line}"
|
521
|
+
end
|
522
|
+
@oldline = @line
|
523
|
+
@line = $'
|
524
|
+
end
|
525
|
+
end while @line = getline
|
526
|
+
yield nil, nil
|
527
|
+
end
|
528
|
+
def do_default
|
529
|
+
master.nodes_code << %{
|
530
|
+
class Node_#{master.lhs_name} < Node
|
531
|
+
def initialize
|
532
|
+
super()
|
533
|
+
end
|
534
|
+
end
|
535
|
+
}; #code
|
536
|
+
end
|
537
|
+
|
538
|
+
end
|
539
|
+
|
540
|
+
### Outer Code
|
541
|
+
|
542
|
+
class D4CSTBuilderExtension_postlhs::NVAction < Depager::Action #:nodoc:all
|
543
|
+
include Depager::DecoratorUtils
|
544
|
+
include ActionParser
|
545
|
+
|
546
|
+
on_reduce = [
|
547
|
+
nil,
|
548
|
+
:_act_0,
|
549
|
+
:_act_1,
|
550
|
+
:_act_2,
|
551
|
+
:_act_3,
|
552
|
+
:_act_4,
|
553
|
+
|
554
|
+
]
|
555
|
+
Tables = [on_reduce]
|
556
|
+
def initialize inside
|
557
|
+
super inside, 'NVAction'
|
558
|
+
@on_reduce, = self.class::Tables
|
559
|
+
init_parser
|
560
|
+
end
|
561
|
+
|
562
|
+
|
563
|
+
module_eval <<-'.,.,118028145927473.,.,', 'cst.dr', 153
|
564
|
+
def _act_0 val
|
565
|
+
_, _pair, _ = *val
|
566
|
+
|
567
|
+
args = []; code = ''
|
568
|
+
_pair.each do |id, lit|
|
569
|
+
args << id
|
570
|
+
code << "#{id} = #{lit}; " if lit
|
571
|
+
end
|
572
|
+
attrc = args.map{|i| ":#{i}"}.join(', ')
|
573
|
+
master.nodes_code << %{
|
574
|
+
class Node_#{master.lhs_name} < Node
|
575
|
+
attr_accessor #{attrc}
|
576
|
+
def initialize
|
577
|
+
super()
|
578
|
+
#{code}
|
579
|
+
end
|
580
|
+
end
|
581
|
+
}; #code
|
582
|
+
|
583
|
+
end
|
584
|
+
|
585
|
+
.,.,118028145927473.,.,
|
586
|
+
|
587
|
+
module_eval <<-'.,.,118028145920598.,.,', 'cst.dr', 172
|
588
|
+
def _act_1 val
|
589
|
+
_expr = *val
|
590
|
+
[ _expr ]
|
591
|
+
|
592
|
+
end
|
593
|
+
|
594
|
+
.,.,118028145920598.,.,
|
595
|
+
|
596
|
+
module_eval <<-'.,.,11802814597299.,.,', 'cst.dr', 173
|
597
|
+
def _act_2 val
|
598
|
+
_pair, _, _expr = *val
|
599
|
+
_pair << _expr
|
600
|
+
|
601
|
+
end
|
602
|
+
|
603
|
+
.,.,11802814597299.,.,
|
604
|
+
|
605
|
+
module_eval <<-'.,.,118028145933452.,.,', 'cst.dr', 176
|
606
|
+
def _act_3 val
|
607
|
+
_ID = *val
|
608
|
+
[ _ID.value, nil]
|
609
|
+
|
610
|
+
end
|
611
|
+
|
612
|
+
.,.,118028145933452.,.,
|
613
|
+
|
614
|
+
module_eval <<-'.,.,118028145946002.,.,', 'cst.dr', 177
|
615
|
+
def _act_4 val
|
616
|
+
_ID, _, _LIT = *val
|
617
|
+
[ _ID.value, _LIT.value ]
|
618
|
+
|
619
|
+
end
|
620
|
+
|
621
|
+
.,.,118028145946002.,.,
|
622
|
+
|
623
|
+
end
|
624
|
+
|
625
|
+
|