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
data/lib/depager.rb
CHANGED
@@ -11,30 +11,47 @@ module Depager
|
|
11
11
|
#
|
12
12
|
class FileManager
|
13
13
|
def initialize f=nil
|
14
|
-
@
|
14
|
+
@files = []
|
15
|
+
@files << f if f
|
15
16
|
end
|
16
|
-
def
|
17
|
-
@file = f
|
17
|
+
def __file= f
|
18
|
+
# @file = f
|
18
19
|
end
|
19
20
|
def eof?
|
20
|
-
|
21
|
+
ceof = current.eof?
|
22
|
+
if !ceof
|
23
|
+
ceof
|
24
|
+
elsif @files.size == 1
|
25
|
+
ceof
|
26
|
+
else
|
27
|
+
@files.pop
|
28
|
+
self.eof?
|
29
|
+
end
|
21
30
|
end
|
22
31
|
# get file name
|
23
32
|
def fname
|
24
|
-
File.basename
|
33
|
+
File.basename current.path
|
25
34
|
end
|
26
35
|
# get file path
|
27
36
|
def path
|
28
|
-
|
37
|
+
current.path
|
29
38
|
end
|
30
39
|
# get current line no
|
31
40
|
def lineno
|
32
|
-
|
41
|
+
current.lineno
|
42
|
+
end
|
43
|
+
# add file to files
|
44
|
+
def add_file f
|
45
|
+
@files << f
|
46
|
+
end
|
47
|
+
#current file
|
48
|
+
def current
|
49
|
+
@files.last
|
33
50
|
end
|
34
51
|
|
35
52
|
# get next line
|
36
53
|
def getline
|
37
|
-
|
54
|
+
current.gets unless eof?
|
38
55
|
end
|
39
56
|
alias gets getline
|
40
57
|
end
|
@@ -61,9 +78,9 @@ module Depager
|
|
61
78
|
case line = files.getline
|
62
79
|
when /^\s*(#.*)?$/
|
63
80
|
#skip space and comment.
|
64
|
-
when /^%class\s+(\S+)\s+based_on\s+(\S+)\s+\(\s*'(.+)'\s*\)
|
81
|
+
when /^%class\s+(\S+)\s+based_on\s+(\S+)(\s+\(\s*'(.+)'\s*\))?\s*$/
|
65
82
|
@target_name = $1
|
66
|
-
require $
|
83
|
+
require $4 if $4
|
67
84
|
ns = $2.split(/::/)
|
68
85
|
ge = ns.pop
|
69
86
|
m = ns.inject(Object){|c,name| c.const_get(name) }
|
@@ -186,7 +203,13 @@ module Depager
|
|
186
203
|
public
|
187
204
|
def gettoken
|
188
205
|
while !@line.empty? || !eof?
|
189
|
-
|
206
|
+
if @line.empty?
|
207
|
+
getline
|
208
|
+
if @line =~ /^%include\s+'(.+?)'\s*$/
|
209
|
+
files.add_file File.open($1)
|
210
|
+
@line = ''
|
211
|
+
end
|
212
|
+
end
|
190
213
|
@oldline = @line
|
191
214
|
tag = s = name = val = nil
|
192
215
|
until @line.empty? do
|
@@ -206,7 +229,7 @@ module Depager
|
|
206
229
|
s = $1.intern
|
207
230
|
name = $3 ? $3 : $1
|
208
231
|
val = @terms[s] ||= - (@terms.size + 1)
|
209
|
-
when /^'(
|
232
|
+
when /^'(.+?)'/
|
210
233
|
tag = :T
|
211
234
|
name = s = $1
|
212
235
|
val = @terms[s] ||= - (@terms.size + 1)
|
@@ -287,7 +310,7 @@ module Depager
|
|
287
310
|
def add_rule lhs, rhs, prec=nil
|
288
311
|
@lhs_syms[lhs] = true
|
289
312
|
rule = @parsing_method::Rule[lhs, rhs, prec]
|
290
|
-
@
|
313
|
+
@rules.push rule
|
291
314
|
return rule
|
292
315
|
end
|
293
316
|
|
@@ -312,7 +335,7 @@ module Depager
|
|
312
335
|
end
|
313
336
|
end
|
314
337
|
|
315
|
-
attr_accessor :
|
338
|
+
attr_accessor :rules, :terms, :nonterms, :precs
|
316
339
|
attr_accessor :line, :line0, :oldline, :token
|
317
340
|
attr_accessor :optouter, :optinner, :optmain, :mixin
|
318
341
|
attr_accessor :nparams, :lhs, :rhs, :nrhs, :rhsni, :nparam, :nrules
|
@@ -357,7 +380,7 @@ module Depager
|
|
357
380
|
def make_grammar precs
|
358
381
|
ts = @nonterms.size - 1
|
359
382
|
@terms.each{|k,v| @terms[k] = ts - v}
|
360
|
-
@
|
383
|
+
# @grammar[0].act = Array.new(@nparam-1)
|
361
384
|
|
362
385
|
@precs = {}
|
363
386
|
precs.each_with_index do |p, x|
|
@@ -369,9 +392,9 @@ module Depager
|
|
369
392
|
end
|
370
393
|
end
|
371
394
|
end
|
372
|
-
@
|
373
|
-
|
374
|
-
|
395
|
+
@rules.each do |rule|
|
396
|
+
rule.rhs.each_with_index{|i, x| rule.rhs[x] = ts - i if i < 0}
|
397
|
+
rule.prec &&= @precs[@terms[rule.prec]]
|
375
398
|
end
|
376
399
|
end
|
377
400
|
alias mkg make_grammar
|
@@ -396,7 +419,7 @@ module Depager
|
|
396
419
|
end
|
397
420
|
|
398
421
|
def init_grammar
|
399
|
-
@
|
422
|
+
@rules = [@parsing_method::Rule[0 , [1]]]
|
400
423
|
@terms = { nil => -1, false => -2 }
|
401
424
|
@nonterms = {'$start' => 0}
|
402
425
|
@i2s = {}
|
@@ -406,12 +429,21 @@ module Depager
|
|
406
429
|
|
407
430
|
public
|
408
431
|
# extend paser
|
409
|
-
#
|
410
|
-
|
432
|
+
# extentions:: array of [name, paht]
|
433
|
+
# options:: hash of options
|
434
|
+
def extend_paser extentions, options
|
411
435
|
init_hook
|
412
|
-
|
436
|
+
extentions.each do |f,m|
|
413
437
|
require f if f
|
414
|
-
Object.const_get("#{m}Extension").new
|
438
|
+
e = Object.const_get("#{m}Extension").new
|
439
|
+
options[m] and options[m].each do |k,v|
|
440
|
+
begin
|
441
|
+
e.send("#{k}=", v)
|
442
|
+
rescue NoMethodError
|
443
|
+
warning "no such a option '#{m}.#{k}'."
|
444
|
+
end
|
445
|
+
end
|
446
|
+
e.send(:__regext__, self)
|
415
447
|
end
|
416
448
|
end
|
417
449
|
|
@@ -438,7 +470,7 @@ module Depager
|
|
438
470
|
check_grammar
|
439
471
|
make_grammar precs
|
440
472
|
@table = @parsing_method::Table.new(
|
441
|
-
@parsing_method::Grammar.new(@
|
473
|
+
@parsing_method::Grammar.new(@rules, @terms, @nonterms, @precs))
|
442
474
|
@table.check_table @d_parser
|
443
475
|
@table
|
444
476
|
end
|
@@ -464,7 +496,7 @@ module Depager
|
|
464
496
|
end
|
465
497
|
attr_reader :d_parser, :parsing_method
|
466
498
|
attr_accessor :optouter, :optinner, :optmain
|
467
|
-
attr_accessor :basis_name, :deco, :req
|
499
|
+
attr_accessor :basis_name, :deco, :req, :options
|
468
500
|
def initialize d_parser
|
469
501
|
@d_parser = d_parser
|
470
502
|
@parsing_method = nil
|
@@ -473,6 +505,7 @@ module Depager
|
|
473
505
|
@deco = []
|
474
506
|
@req = []
|
475
507
|
@ext = []
|
508
|
+
@options = {}
|
476
509
|
|
477
510
|
@optinner = []
|
478
511
|
@optouter = []
|
@@ -480,6 +513,8 @@ module Depager
|
|
480
513
|
@precs = []
|
481
514
|
@mixin = []
|
482
515
|
|
516
|
+
@dr_option = {}
|
517
|
+
|
483
518
|
@tmpldir = Generator::Tmpldir+'/'
|
484
519
|
end
|
485
520
|
|
@@ -487,9 +522,11 @@ module Depager
|
|
487
522
|
precs = []
|
488
523
|
until files.eof?
|
489
524
|
case line = files.getline
|
525
|
+
when /^\s*$/, /^\s*#.*$/
|
526
|
+
# skip
|
490
527
|
when /^\s*(left|right|nonassoc)\s+(.*)$/
|
491
528
|
dir = $1.upcase.intern
|
492
|
-
syms = $2.split.map{|i| (i =~ /'(
|
529
|
+
syms = $2.split.map{|i| (i =~ /'(.+?)'/) ? $1 : i.intern}
|
493
530
|
precs.push [dir, syms]
|
494
531
|
when /^%\}\s*$/
|
495
532
|
break
|
@@ -521,10 +558,13 @@ module Depager
|
|
521
558
|
@deco.push $1
|
522
559
|
when /^%extend\s+(.*?)\s*\(\s*'(.*)'\s*\)\s*$/
|
523
560
|
@ext.push [$2.strip, $1] unless @ext.find{|i| i[1] == $1}
|
524
|
-
when /^%
|
525
|
-
|
526
|
-
|
527
|
-
|
561
|
+
when /^%option\s+(\w+).(\w+)\s+(.*)\s*$/
|
562
|
+
if $1 == 'Generator'
|
563
|
+
@dr_option[$2] = $3
|
564
|
+
else
|
565
|
+
@options[$1] ||= []
|
566
|
+
@options[$1] << [$2, $3]
|
567
|
+
end
|
528
568
|
when /^%require\s+'(.+?)'\s*$/
|
529
569
|
@req.push "'#{$1}'"
|
530
570
|
when /^%mixin\s+(\S+)\s*(\((.+)\)\s*)?$/
|
@@ -532,14 +572,6 @@ module Depager
|
|
532
572
|
@req.push $3 if $3
|
533
573
|
when /^%inner\s*\{\s*$/
|
534
574
|
@optinner.push parse_block
|
535
|
-
when /^%outer\s*\{\s*$/
|
536
|
-
# obsolete
|
537
|
-
warning "'%optouter' is obsolete."
|
538
|
-
@optouter.push parse_block
|
539
|
-
when /^%main\s*\{\s*$/
|
540
|
-
# obsolete
|
541
|
-
warning "'%optmain' is obsolete."
|
542
|
-
@optmain.push parse_block
|
543
575
|
when /^%prec\s*\{\s*$/
|
544
576
|
@precs = parse_prec
|
545
577
|
else
|
@@ -550,13 +582,14 @@ module Depager
|
|
550
582
|
|
551
583
|
|
552
584
|
module Simple
|
553
|
-
|
554
|
-
|
555
|
-
end
|
556
|
-
end
|
585
|
+
Grammar = Depager::ParsingMethod::Grammar
|
586
|
+
Rule = Depager::ParsingMethod::Rule
|
557
587
|
class Table
|
558
588
|
def initialize *args
|
559
589
|
end
|
590
|
+
def check_table *args
|
591
|
+
true
|
592
|
+
end
|
560
593
|
end
|
561
594
|
class SingleGenerator < Generator
|
562
595
|
Tmplfile = 'simple.erb'
|
@@ -573,7 +606,7 @@ module Depager
|
|
573
606
|
case line
|
574
607
|
when /^%%\s*$/
|
575
608
|
g_parser = GrammarParser.new(@d_parser)
|
576
|
-
g_parser.extend_paser @ext
|
609
|
+
g_parser.extend_paser @ext, @options
|
577
610
|
g_parser.parse(@d_parser.target_name, @mixin, @precs)
|
578
611
|
@optmain.push parse_block
|
579
612
|
return out_code(g_parser)
|
@@ -654,7 +687,7 @@ module Depager
|
|
654
687
|
precs = parse_prec
|
655
688
|
when /^%%\s*$/
|
656
689
|
g_parser = GrammarParser.new(@d_parser)
|
657
|
-
g_parser.extend_paser @ext
|
690
|
+
g_parser.extend_paser @ext, @options
|
658
691
|
g_parser.parse(target_name, mixin, precs)
|
659
692
|
g_parser.optinner.push inner
|
660
693
|
return out_slave_code(g_parser, mixin, mtsk, banner)
|
@@ -1,4 +1,4 @@
|
|
1
|
-
%defext
|
1
|
+
%defext ASTBuilderExtension
|
2
2
|
%extend Lexer ('depager/lex.rb')
|
3
3
|
%extend NVAction ('depager/nvaction.rb')
|
4
4
|
%decorate @NVAction
|
@@ -10,12 +10,32 @@
|
|
10
10
|
@visitor = Hash.new{|hash, key| hash[key] = []}
|
11
11
|
@optouter = []
|
12
12
|
@on_reduce = []
|
13
|
+
@output_file_name = nil
|
13
14
|
end
|
14
15
|
def postRuleList
|
15
16
|
g_parser.optouter <<
|
16
17
|
gen_action_decorator_code(target_name, paramkey,
|
17
18
|
@on_reduce, @optouter)
|
18
19
|
end
|
20
|
+
|
21
|
+
Template = CodeUtils::make_tmpl("#{Depager::Tmpldir}/ast.erbs")
|
22
|
+
def modify_action_code code, nodes=[]
|
23
|
+
code = code.gsub(/\$\.([a-z_])/, 'node.\1')
|
24
|
+
code << %{
|
25
|
+
rescue
|
26
|
+
warn "raise at src:\#{node.lineno}/\#{node.class.name}"
|
27
|
+
raise
|
28
|
+
}
|
29
|
+
end
|
30
|
+
def gen_accept_code sym
|
31
|
+
return ''
|
32
|
+
end
|
33
|
+
|
34
|
+
attr_reader :output_file_name
|
35
|
+
def output_file_name= ofname
|
36
|
+
ofname = ofname.match(/'(.+)'/) ? $1 : ofname
|
37
|
+
@output_file_name = ofname
|
38
|
+
end
|
19
39
|
%}
|
20
40
|
%hook prerulelist /%AST\{\s*\Z/ skip
|
21
41
|
%banner '%AST{ ... }'
|
@@ -36,21 +56,30 @@
|
|
36
56
|
start:
|
37
57
|
opt_defnode opt_defvis defnode_list
|
38
58
|
{
|
39
|
-
|
40
|
-
|
59
|
+
code = _opt_defnode
|
60
|
+
code << val[2] << %{
|
41
61
|
class Visitor
|
42
62
|
def visit node
|
43
63
|
node.accept(self)
|
44
64
|
end
|
45
|
-
#{master.visitor[nil]}
|
65
|
+
#{master.visitor[nil].join}
|
46
66
|
end
|
47
67
|
};#code
|
48
68
|
master.visitor.each do |k, v|
|
49
|
-
|
69
|
+
next unless k
|
70
|
+
code << %{
|
50
71
|
class Visitor_#{k}
|
51
|
-
#{v}
|
72
|
+
#{v.join}
|
52
73
|
end
|
53
|
-
}
|
74
|
+
};#code
|
75
|
+
end
|
76
|
+
if master.output_file_name
|
77
|
+
File.open(master.output_file_name, 'w') do |f|
|
78
|
+
f.write code
|
79
|
+
end
|
80
|
+
g_parser.optouter << %!require '#{master.output_file_name}'\n!
|
81
|
+
else
|
82
|
+
g_parser.optouter << code
|
54
83
|
end
|
55
84
|
}
|
56
85
|
;
|
@@ -70,7 +99,7 @@
|
|
70
99
|
{ [] }
|
71
100
|
| VISITOR opt_action
|
72
101
|
{
|
73
|
-
_opt_action[nil]
|
102
|
+
_opt_action[nil] ||= Token['', 0]
|
74
103
|
_opt_action.each do |pass, act|
|
75
104
|
master.visitor[pass].unshift(
|
76
105
|
master.gen_meval_code(act.lineno, 0, act.value.to_s))
|
@@ -106,7 +135,7 @@
|
|
106
135
|
}
|
107
136
|
;
|
108
137
|
defnode_header:
|
109
|
-
ID '(' ')' { [_ID.value,
|
138
|
+
ID '(' ')' { [_ID.value, []]}
|
110
139
|
| ID '(' fact_list ')' { [_ID.value, _fact_list] }
|
111
140
|
;
|
112
141
|
opt_attr:
|
@@ -131,11 +160,11 @@
|
|
131
160
|
| ACTION { {nil => _ACTION} }
|
132
161
|
| pass_action_list
|
133
162
|
{
|
134
|
-
Hash
|
163
|
+
Hash[ *_pass_action_list.flatten ].merge({nil => Token['', 0]})
|
135
164
|
}
|
136
165
|
;
|
137
166
|
pass_action_list:
|
138
|
-
pass_action { _pass_action }
|
167
|
+
pass_action { [ _pass_action ] }
|
139
168
|
| pass_action_list pass_action { _pass_action_list << _pass_action }
|
140
169
|
;
|
141
170
|
|
@@ -144,22 +173,30 @@
|
|
144
173
|
;
|
145
174
|
#end-rule
|
146
175
|
%%
|
147
|
-
%hook postrhs
|
176
|
+
%hook postrhs /=>/ skip
|
148
177
|
%banner '=>...'
|
149
178
|
%prec{
|
150
179
|
left LL '@'
|
151
180
|
%}
|
181
|
+
%inner{
|
182
|
+
def do_default
|
183
|
+
n = master.nrules
|
184
|
+
master.optouter <<
|
185
|
+
master.gen_defm_code("_ast_#{n} val", "NilNode.new(basis.file.lineno)", lineno)
|
186
|
+
master.on_reduce[n] = ":_ast_#{n}"
|
187
|
+
end
|
188
|
+
%}
|
152
189
|
%%
|
153
190
|
|
154
191
|
%LEX{
|
155
192
|
/[ \t]+/ { }
|
156
193
|
/\r?\n/ { yield nil, nil }
|
157
194
|
/<</ { yield _Token(:LL, $&) }
|
158
|
-
/=>/ { yield _Token(:EG, $&) }
|
159
195
|
/%([a-zA-Z0-9_]+)((::[a-zA-Z0-9_]+)*)/
|
160
196
|
{ yield _Token(:CONST, $1+$2) }
|
161
197
|
/%\((.+)\)%/ { yield _Token(:EMBED, $1) }
|
162
198
|
'nil' { yield _Token(:NIL, $&) }
|
199
|
+
'NilNode' { yield _Token(:NILNODE, $&) }
|
163
200
|
/[0-9]+/ { yield _Token(:NUMBER, $&.to_i) }
|
164
201
|
/:[a-zA-Z0-9_]+/ { yield _Token(:SYMBOL, $&) }
|
165
202
|
/[a-zA-Z][a-zA-Z0-9_]*/ { yield _Token(:ID, $&) }
|
@@ -168,11 +205,11 @@
|
|
168
205
|
%}
|
169
206
|
#begin-rule
|
170
207
|
start:
|
171
|
-
|
208
|
+
fnl
|
172
209
|
{
|
173
210
|
n = master.nrules
|
174
211
|
master.optouter <<
|
175
|
-
master.gen_defm_code("_ast_#{n} val", _fnl,
|
212
|
+
master.gen_defm_code("_ast_#{n} val", _fnl, basis.file.lineno)
|
176
213
|
master.on_reduce[n] = ":_ast_#{n}"
|
177
214
|
}
|
178
215
|
;
|
@@ -199,8 +236,8 @@
|
|
199
236
|
fact:
|
200
237
|
ID opt_embed
|
201
238
|
{
|
202
|
-
unless i = g_parser.name_to_rhs_index(
|
203
|
-
warn "#{g_parser.lineno}: ?#{
|
239
|
+
unless i = g_parser.name_to_rhs_index(_ID.value)
|
240
|
+
warn "#{g_parser.lineno}: ?#{_ID.value}"
|
204
241
|
raise
|
205
242
|
end
|
206
243
|
"val[#{i}]#{val[1]}"
|
@@ -208,8 +245,9 @@
|
|
208
245
|
| CONST { "Depager::Token[#{_CONST.value}]" }
|
209
246
|
| SYMBOL { "Depager::Token[#{_SYMBOL.value}]" }
|
210
247
|
| STR { "Depager::Token['#{_STR.value}']" }
|
211
|
-
|
|
248
|
+
| NILNODE { "NilNode.new(basis.file.lineno)" }
|
212
249
|
| NUMBER { "Depager::Token[#{_NUMBER.value}]" }
|
250
|
+
| NIL { "nil" }
|
213
251
|
;
|
214
252
|
opt_embed:
|
215
253
|
{ '' }
|
@@ -1,16 +1,16 @@
|
|
1
1
|
|
2
2
|
###
|
3
|
-
###
|
3
|
+
### ASTBuilderExtension - Depager Extension (master)
|
4
4
|
###
|
5
5
|
require 'pp.rb'
|
6
6
|
require 'depager/parser.rb'
|
7
7
|
require 'depager/parse_action'
|
8
8
|
|
9
9
|
|
10
|
-
module
|
10
|
+
module D4ASTBuilderExtension #:nodoc:all
|
11
11
|
end
|
12
12
|
|
13
|
-
class
|
13
|
+
class ASTBuilderExtension #:nodoc:all
|
14
14
|
include Depager::ExtensionUtils
|
15
15
|
|
16
16
|
attr_accessor :h2p
|
@@ -25,11 +25,11 @@ class ASTBuilderBaseExtension #:nodoc:all
|
|
25
25
|
def __regext__ p
|
26
26
|
super p, :default, nil
|
27
27
|
|
28
|
-
@hook[0] =
|
28
|
+
@hook[0] = ASTBuilderExtension_prerulelist.new(p, @nparam, self)
|
29
29
|
@h2p['prerulelist'] = @hook[0]
|
30
30
|
p.prerulelist.push [@hook[0], :do_parse]
|
31
31
|
|
32
|
-
@hook[1] =
|
32
|
+
@hook[1] = ASTBuilderExtension_postrhs.new(p, @nparam, self)
|
33
33
|
@h2p['postrhs'] = @hook[1]
|
34
34
|
p.postrhs.push [@hook[1], :do_parse]
|
35
35
|
|
@@ -43,6 +43,7 @@ class ASTBuilderBaseExtension #:nodoc:all
|
|
43
43
|
@visitor = Hash.new{|hash, key| hash[key] = []}
|
44
44
|
@optouter = []
|
45
45
|
@on_reduce = []
|
46
|
+
@output_file_name = nil
|
46
47
|
end
|
47
48
|
def postRuleList
|
48
49
|
g_parser.optouter <<
|
@@ -50,17 +51,36 @@ class ASTBuilderBaseExtension #:nodoc:all
|
|
50
51
|
@on_reduce, @optouter)
|
51
52
|
end
|
52
53
|
|
54
|
+
Template = CodeUtils::make_tmpl("#{Depager::Tmpldir}/ast.erbs")
|
55
|
+
def modify_action_code code, nodes=[]
|
56
|
+
code = code.gsub(/\$\.([a-z_])/, 'node.\1')
|
57
|
+
code << %{
|
58
|
+
rescue
|
59
|
+
warn "raise at src:\#{node.lineno}/\#{node.class.name}"
|
60
|
+
raise
|
61
|
+
}
|
62
|
+
end
|
63
|
+
def gen_accept_code sym
|
64
|
+
return ''
|
65
|
+
end
|
66
|
+
|
67
|
+
attr_reader :output_file_name
|
68
|
+
def output_file_name= ofname
|
69
|
+
ofname = ofname.match(/'(.+)'/) ? $1 : ofname
|
70
|
+
@output_file_name = ofname
|
71
|
+
end
|
72
|
+
|
53
73
|
end
|
54
74
|
|
55
75
|
### Outer Code
|
56
76
|
|
57
77
|
###
|
58
|
-
###
|
78
|
+
### ASTBuilderExtension_prerulelist - Part of Depager Extension (slave)
|
59
79
|
###
|
60
|
-
module
|
80
|
+
module D4ASTBuilderExtension_prerulelist #:nodoc:all
|
61
81
|
end
|
62
82
|
|
63
|
-
class
|
83
|
+
class ASTBuilderExtension_prerulelist < Depager::LALR::Basis #:nodoc:all
|
64
84
|
include Depager::ExtensionUtils
|
65
85
|
|
66
86
|
include ActionParser
|
@@ -134,90 +154,90 @@ class ASTBuilderBaseExtension_prerulelist < Depager::LALR::Basis #:nodoc:all
|
|
134
154
|
]
|
135
155
|
### Action Table
|
136
156
|
action_table = [
|
137
|
-
[ nil, nil,
|
138
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, 5, nil, nil, nil, nil, nil, ],
|
157
|
+
[ nil, nil, 3, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
139
158
|
[ ACC, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
140
|
-
[ nil, nil, nil, nil,
|
141
|
-
[ nil, nil, nil,
|
142
|
-
[ nil, nil, nil, nil, nil,
|
143
|
-
[ nil, nil, nil,
|
144
|
-
[ nil, nil, nil,
|
159
|
+
[ nil, nil, nil, nil, 5, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
160
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, 7, nil, nil, nil, nil, nil, ],
|
161
|
+
[ nil, nil, nil, nil, nil, 11, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
162
|
+
[ nil, nil, nil, 13, nil, nil, nil, nil, nil, nil, nil, nil, 16, nil, ],
|
163
|
+
[ nil, nil, nil, 17, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
164
|
+
[ nil, nil, nil, nil, nil, 20, nil, nil, nil, 18, nil, nil, nil, nil, ],
|
165
|
+
[ nil, nil, nil, nil, nil, 11, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
145
166
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
167
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, 7, nil, nil, nil, nil, nil, ],
|
168
|
+
[ nil, nil, nil, nil, nil, nil, 23, nil, nil, nil, nil, nil, nil, nil, ],
|
146
169
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
147
170
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
148
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
171
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 16, nil, ],
|
149
172
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
173
|
+
[ nil, nil, nil, nil, nil, 25, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
150
174
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
151
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 16, nil, ],
|
152
175
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
153
|
-
[ nil, nil, nil, nil, nil,
|
176
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, 26, 27, nil, nil, nil, ],
|
154
177
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
155
|
-
[ nil, nil, nil, nil, nil, nil, 25, nil, nil, nil, nil, nil, nil, nil, ],
|
156
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, 5, nil, nil, nil, nil, nil, ],
|
157
|
-
[ nil, nil, nil, nil, nil, 18, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
158
178
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
159
|
-
[ nil, nil, nil,
|
179
|
+
[ nil, nil, nil, 13, nil, nil, nil, nil, nil, nil, nil, nil, 16, nil, ],
|
180
|
+
[ nil, nil, nil, nil, nil, 32, nil, 29, nil, nil, nil, 33, nil, nil, ],
|
160
181
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
161
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil,
|
162
|
-
[ nil, nil, nil, nil, nil, 31, nil, 34, nil, nil, nil, 32, nil, nil, ],
|
163
|
-
[ nil, nil, nil, 12, nil, nil, nil, nil, nil, nil, nil, nil, 16, nil, ],
|
182
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 34, ],
|
164
183
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
184
|
+
[ nil, nil, nil, nil, nil, 35, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
165
185
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
166
|
-
[ nil, nil, nil, 36, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
167
186
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
187
|
+
[ nil, nil, nil, nil, nil, nil, nil, 36, nil, nil, 37, nil, nil, nil, ],
|
168
188
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
169
|
-
[ nil, nil, nil, nil, nil, 37, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
170
|
-
[ nil, nil, nil, nil, nil, nil, nil, 39, nil, nil, 38, nil, nil, nil, ],
|
171
189
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
190
|
+
[ nil, nil, nil, nil, nil, 38, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
191
|
+
[ nil, nil, nil, 39, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
172
192
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
173
193
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
194
|
+
[ nil, nil, nil, nil, nil, 32, nil, nil, nil, nil, nil, 33, nil, nil, ],
|
174
195
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
175
|
-
[ nil, nil, nil, nil, nil, 31, nil, nil, nil, nil, nil, 32, nil, nil, ],
|
176
196
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
177
197
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
178
198
|
]
|
179
199
|
### Default Reduce Table
|
180
200
|
defred_table = [
|
181
201
|
-2,
|
182
|
-
-11,
|
183
202
|
nil,
|
184
203
|
-4,
|
185
|
-
|
204
|
+
-11,
|
186
205
|
nil,
|
187
206
|
-20,
|
188
207
|
nil,
|
189
|
-
-3,
|
190
|
-
-12,
|
191
|
-
-18,
|
192
208
|
nil,
|
193
|
-
-
|
209
|
+
-1,
|
210
|
+
-6,
|
211
|
+
-11,
|
212
|
+
nil,
|
194
213
|
-5,
|
214
|
+
-21,
|
195
215
|
-22,
|
196
216
|
-23,
|
197
217
|
nil,
|
198
|
-
-
|
218
|
+
-3,
|
219
|
+
-12,
|
199
220
|
nil,
|
200
|
-
-
|
201
|
-
-
|
202
|
-
-
|
221
|
+
-18,
|
222
|
+
-7,
|
223
|
+
-20,
|
203
224
|
nil,
|
204
225
|
-24,
|
205
226
|
nil,
|
227
|
+
-13,
|
206
228
|
nil,
|
207
|
-
-
|
208
|
-
-
|
209
|
-
-19,
|
229
|
+
-8,
|
230
|
+
-9,
|
210
231
|
nil,
|
211
232
|
-14,
|
212
233
|
-16,
|
213
234
|
nil,
|
214
235
|
nil,
|
215
|
-
-
|
216
|
-
-8,
|
217
|
-
-25,
|
218
|
-
-17,
|
219
|
-
nil,
|
236
|
+
-19,
|
220
237
|
-10,
|
238
|
+
nil,
|
239
|
+
-17,
|
240
|
+
-25,
|
221
241
|
-15,
|
222
242
|
]
|
223
243
|
defred_after_shift_table = [
|
@@ -229,38 +249,38 @@ class ASTBuilderBaseExtension_prerulelist < Depager::LALR::Basis #:nodoc:all
|
|
229
249
|
nil,
|
230
250
|
nil,
|
231
251
|
nil,
|
232
|
-
-3,
|
233
|
-
-12,
|
234
|
-
-18,
|
235
252
|
nil,
|
236
|
-
-
|
253
|
+
-6,
|
254
|
+
nil,
|
255
|
+
nil,
|
237
256
|
-5,
|
257
|
+
-21,
|
238
258
|
nil,
|
239
259
|
-23,
|
240
260
|
nil,
|
241
|
-
-
|
242
|
-
|
261
|
+
-3,
|
262
|
+
-12,
|
243
263
|
nil,
|
264
|
+
-18,
|
265
|
+
-7,
|
244
266
|
nil,
|
245
|
-
-13,
|
246
267
|
nil,
|
247
268
|
-24,
|
248
269
|
nil,
|
270
|
+
-13,
|
249
271
|
nil,
|
250
|
-
|
251
|
-
-
|
252
|
-
-19,
|
272
|
+
-8,
|
273
|
+
-9,
|
253
274
|
nil,
|
254
275
|
-14,
|
255
276
|
-16,
|
256
277
|
nil,
|
257
278
|
nil,
|
258
|
-
-
|
259
|
-
-8,
|
260
|
-
-25,
|
261
|
-
-17,
|
262
|
-
nil,
|
279
|
+
-19,
|
263
280
|
-10,
|
281
|
+
nil,
|
282
|
+
-17,
|
283
|
+
-25,
|
264
284
|
-15,
|
265
285
|
]
|
266
286
|
### Nonterm to Int
|
@@ -297,33 +317,32 @@ class ASTBuilderBaseExtension_prerulelist < Depager::LALR::Basis #:nodoc:all
|
|
297
317
|
]
|
298
318
|
### Goto Table
|
299
319
|
goto_table = [
|
300
|
-
[
|
301
|
-
[ nil, nil, nil, nil, 4, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
302
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
303
|
-
[ nil, nil, 7, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
320
|
+
[ 1, 2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
304
321
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
305
|
-
[ nil, nil,
|
306
|
-
[ nil, nil, nil, nil,
|
307
|
-
[ nil, nil, nil,
|
322
|
+
[ nil, nil, 4, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
323
|
+
[ nil, nil, nil, nil, 6, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
324
|
+
[ nil, nil, nil, 8, nil, nil, 9, 10, nil, nil, nil, nil, nil, ],
|
325
|
+
[ nil, nil, nil, nil, nil, 12, nil, nil, nil, nil, nil, 14, 15, ],
|
308
326
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
327
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, 19, nil, nil, nil, ],
|
328
|
+
[ nil, nil, nil, nil, nil, nil, 21, 10, nil, nil, nil, nil, nil, ],
|
309
329
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
330
|
+
[ nil, nil, nil, nil, 22, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
310
331
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
311
332
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
312
333
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
334
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 24, ],
|
313
335
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
314
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 23, ],
|
315
336
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
316
337
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
317
338
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
318
339
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
319
|
-
[ nil, nil, nil, nil, 26, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
320
|
-
[ nil, nil, nil, nil, nil, nil, 27, 19, nil, nil, nil, nil, nil, ],
|
321
340
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
322
341
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
342
|
+
[ nil, nil, nil, nil, nil, 28, nil, nil, nil, nil, nil, 14, 15, ],
|
343
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, 30, nil, 31, nil, nil, ],
|
323
344
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
324
345
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
325
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, 33, nil, 30, nil, nil, ],
|
326
|
-
[ nil, nil, nil, nil, nil, 35, nil, nil, nil, nil, nil, 14, 15, ],
|
327
346
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
328
347
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
329
348
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
@@ -338,6 +357,7 @@ class ASTBuilderBaseExtension_prerulelist < Depager::LALR::Basis #:nodoc:all
|
|
338
357
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 40, nil, nil, ],
|
339
358
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
340
359
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
360
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
341
361
|
]
|
342
362
|
|
343
363
|
Tables = [ reduce_table, nparams, action_table,
|
@@ -350,7 +370,7 @@ class ASTBuilderBaseExtension_prerulelist < Depager::LALR::Basis #:nodoc:all
|
|
350
370
|
@g_parser = @p = p
|
351
371
|
@master = @m = master
|
352
372
|
@nparam = nparam
|
353
|
-
@dect =
|
373
|
+
@dect = D4ASTBuilderExtension_prerulelist::NVAction.new(self)
|
354
374
|
init_parser
|
355
375
|
end
|
356
376
|
|
@@ -423,10 +443,9 @@ end
|
|
423
443
|
|
424
444
|
### Outer Code
|
425
445
|
|
426
|
-
class
|
446
|
+
class D4ASTBuilderExtension_prerulelist::NVAction < Depager::LALR::Action #:nodoc:all
|
427
447
|
include Depager::DecoratorUtils
|
428
|
-
|
429
|
-
|
448
|
+
[" include ActionParser\n"]
|
430
449
|
on_reduce = [
|
431
450
|
nil,
|
432
451
|
:_act_0,
|
@@ -464,42 +483,49 @@ class D4ASTBuilderBaseExtension_prerulelist::NVAction < Depager::LALR::Action #:
|
|
464
483
|
end
|
465
484
|
|
466
485
|
|
467
|
-
module_eval <<-'.,.,
|
468
|
-
|
469
|
-
_opt_defnode, _opt_defvis, _defnode_list = *val
|
486
|
+
module_eval <<-'.,.,120998292244191.,.,', 'ast.dr', 56
|
487
|
+
def _act_0 val
|
488
|
+
_opt_defnode, _opt_defvis, _defnode_list, = *val
|
470
489
|
|
471
|
-
|
472
|
-
|
490
|
+
code = _opt_defnode
|
491
|
+
code << val[2] << %{
|
473
492
|
class Visitor
|
474
493
|
def visit node
|
475
494
|
node.accept(self)
|
476
495
|
end
|
477
|
-
#{master.visitor[nil]}
|
496
|
+
#{master.visitor[nil].join}
|
478
497
|
end
|
479
498
|
};#code
|
480
499
|
master.visitor.each do |k, v|
|
481
|
-
|
500
|
+
next unless k
|
501
|
+
code << %{
|
482
502
|
class Visitor_#{k}
|
483
|
-
#{v}
|
503
|
+
#{v.join}
|
484
504
|
end
|
485
|
-
}
|
505
|
+
};#code
|
506
|
+
end
|
507
|
+
if master.output_file_name
|
508
|
+
File.open(master.output_file_name, 'w') do |f|
|
509
|
+
f.write code
|
510
|
+
end
|
511
|
+
g_parser.optouter << %!require '#{master.output_file_name}'\n!
|
512
|
+
else
|
513
|
+
g_parser.optouter << code
|
486
514
|
end
|
487
515
|
|
488
|
-
|
489
|
-
|
490
|
-
.,.,118754107738065.,.,
|
516
|
+
end
|
517
|
+
.,.,120998292244191.,.,
|
491
518
|
|
492
|
-
module_eval <<-'.,.,
|
493
|
-
|
519
|
+
module_eval <<-'.,.,120998292256836.,.,', 'ast.dr', 85
|
520
|
+
def _act_1 val
|
494
521
|
""
|
495
522
|
|
496
|
-
|
497
|
-
|
498
|
-
.,.,11875410776514.,.,
|
523
|
+
end
|
524
|
+
.,.,120998292256836.,.,
|
499
525
|
|
500
|
-
module_eval <<-'.,.,
|
501
|
-
|
502
|
-
_NODE, _opt_attr, _ACTION = *val
|
526
|
+
module_eval <<-'.,.,120998292239342.,.,', 'ast.dr', 87
|
527
|
+
def _act_2 val
|
528
|
+
_NODE, _opt_attr, _ACTION, = *val
|
503
529
|
|
504
530
|
ini = %{
|
505
531
|
def initialize
|
@@ -508,53 +534,48 @@ module_eval <<-'.,.,118754107720386.,.,', 'ast_base.dr', 58
|
|
508
534
|
};#code
|
509
535
|
master.gen_tmpl_code(:defnode, binding)
|
510
536
|
|
511
|
-
|
512
|
-
|
513
|
-
.,.,118754107720386.,.,
|
537
|
+
end
|
538
|
+
.,.,120998292239342.,.,
|
514
539
|
|
515
|
-
module_eval <<-'.,.,
|
516
|
-
|
540
|
+
module_eval <<-'.,.,120998292263713.,.,', 'ast.dr', 97
|
541
|
+
def _act_3 val
|
517
542
|
[]
|
518
543
|
|
519
|
-
|
520
|
-
|
521
|
-
.,.,118754107736984.,.,
|
544
|
+
end
|
545
|
+
.,.,120998292263713.,.,
|
522
546
|
|
523
|
-
module_eval <<-'.,.,
|
524
|
-
|
525
|
-
_VISITOR, _opt_action = *val
|
547
|
+
module_eval <<-'.,.,120998292220850.,.,', 'ast.dr', 99
|
548
|
+
def _act_4 val
|
549
|
+
_VISITOR, _opt_action, = *val
|
526
550
|
|
527
|
-
_opt_action[nil]
|
551
|
+
_opt_action[nil] ||= Token['', 0]
|
528
552
|
_opt_action.each do |pass, act|
|
529
553
|
master.visitor[pass].unshift(
|
530
554
|
master.gen_meval_code(act.lineno, 0, act.value.to_s))
|
531
555
|
end
|
532
556
|
|
533
|
-
|
534
|
-
|
535
|
-
.,.,118754107764916.,.,
|
557
|
+
end
|
558
|
+
.,.,120998292220850.,.,
|
536
559
|
|
537
|
-
module_eval <<-'.,.,
|
538
|
-
|
539
|
-
_defnode = *val
|
560
|
+
module_eval <<-'.,.,120998292217429.,.,', 'ast.dr', 108
|
561
|
+
def _act_5 val
|
562
|
+
_defnode, = *val
|
540
563
|
_defnode
|
541
564
|
|
542
|
-
|
543
|
-
|
544
|
-
.,.,118754107745518.,.,
|
565
|
+
end
|
566
|
+
.,.,120998292217429.,.,
|
545
567
|
|
546
|
-
module_eval <<-'.,.,
|
547
|
-
|
548
|
-
_defnode_list, _defnode = *val
|
568
|
+
module_eval <<-'.,.,120998292227244.,.,', 'ast.dr', 109
|
569
|
+
def _act_6 val
|
570
|
+
_defnode_list, _defnode, = *val
|
549
571
|
_defnode_list << _defnode
|
550
572
|
|
551
|
-
|
552
|
-
|
553
|
-
.,.,118754107734821.,.,
|
573
|
+
end
|
574
|
+
.,.,120998292227244.,.,
|
554
575
|
|
555
|
-
module_eval <<-'.,.,
|
556
|
-
|
557
|
-
_defnode_header, _opt_attr, _opt_action = *val
|
576
|
+
module_eval <<-'.,.,120998292237122.,.,', 'ast.dr', 113
|
577
|
+
def _act_7 val
|
578
|
+
_defnode_header, _opt_attr, _opt_action, = *val
|
558
579
|
|
559
580
|
name, args = _defnode_header
|
560
581
|
nodes, accept, attrs = [], '', _opt_attr
|
@@ -576,179 +597,161 @@ module_eval <<-'.,.,118754107753400.,.,', 'ast_base.dr', 84
|
|
576
597
|
end
|
577
598
|
master.gen_tmpl_code(:node, binding)
|
578
599
|
|
579
|
-
|
580
|
-
|
581
|
-
.,.,118754107753400.,.,
|
600
|
+
end
|
601
|
+
.,.,120998292237122.,.,
|
582
602
|
|
583
|
-
module_eval <<-'.,.,
|
584
|
-
|
585
|
-
_ID, _, _ = *val
|
586
|
-
[_ID.value,
|
587
|
-
|
588
|
-
end
|
603
|
+
module_eval <<-'.,.,12099829224464.,.,', 'ast.dr', 136
|
604
|
+
def _act_8 val
|
605
|
+
_ID, _, _, = *val
|
606
|
+
[_ID.value, []]
|
589
607
|
|
590
|
-
|
608
|
+
end
|
609
|
+
.,.,12099829224464.,.,
|
591
610
|
|
592
|
-
module_eval <<-'.,.,
|
593
|
-
|
594
|
-
_ID, _, _fact_list, _ = *val
|
611
|
+
module_eval <<-'.,.,120998292227496.,.,', 'ast.dr', 137
|
612
|
+
def _act_9 val
|
613
|
+
_ID, _, _fact_list, _, = *val
|
595
614
|
[_ID.value, _fact_list]
|
596
615
|
|
597
|
-
|
598
|
-
|
599
|
-
.,.,118754107756494.,.,
|
616
|
+
end
|
617
|
+
.,.,120998292227496.,.,
|
600
618
|
|
601
|
-
module_eval <<-'.,.,
|
602
|
-
|
619
|
+
module_eval <<-'.,.,120998292215500.,.,', 'ast.dr', 140
|
620
|
+
def _act_10 val
|
603
621
|
[]
|
604
622
|
|
605
|
-
|
606
|
-
|
607
|
-
.,.,118754107730627.,.,
|
623
|
+
end
|
624
|
+
.,.,120998292215500.,.,
|
608
625
|
|
609
|
-
module_eval <<-'.,.,
|
610
|
-
|
611
|
-
_, _ = *val
|
626
|
+
module_eval <<-'.,.,120998292236961.,.,', 'ast.dr', 141
|
627
|
+
def _act_11 val
|
628
|
+
_, _, = *val
|
612
629
|
[]
|
613
630
|
|
614
|
-
|
615
|
-
|
616
|
-
.,.,118754107717207.,.,
|
631
|
+
end
|
632
|
+
.,.,120998292236961.,.,
|
617
633
|
|
618
|
-
module_eval <<-'.,.,
|
619
|
-
|
620
|
-
_, _id_list, _ = *val
|
634
|
+
module_eval <<-'.,.,120998292252270.,.,', 'ast.dr', 142
|
635
|
+
def _act_12 val
|
636
|
+
_, _id_list, _, = *val
|
621
637
|
_id_list
|
622
638
|
|
623
|
-
|
624
|
-
|
625
|
-
.,.,118754107738971.,.,
|
639
|
+
end
|
640
|
+
.,.,120998292252270.,.,
|
626
641
|
|
627
|
-
module_eval <<-'.,.,
|
628
|
-
|
629
|
-
_fact = *val
|
642
|
+
module_eval <<-'.,.,120998292239043.,.,', 'ast.dr', 145
|
643
|
+
def _act_13 val
|
644
|
+
_fact, = *val
|
630
645
|
[_fact]
|
631
646
|
|
632
|
-
|
633
|
-
|
634
|
-
.,.,118754107752060.,.,
|
647
|
+
end
|
648
|
+
.,.,120998292239043.,.,
|
635
649
|
|
636
|
-
module_eval <<-'.,.,
|
637
|
-
|
638
|
-
_fact_list, _, _fact = *val
|
650
|
+
module_eval <<-'.,.,120998292235915.,.,', 'ast.dr', 146
|
651
|
+
def _act_14 val
|
652
|
+
_fact_list, _, _fact, = *val
|
639
653
|
_fact_list.push _fact
|
640
654
|
|
641
|
-
|
642
|
-
|
643
|
-
.,.,118754107715890.,.,
|
655
|
+
end
|
656
|
+
.,.,120998292235915.,.,
|
644
657
|
|
645
|
-
module_eval <<-'.,.,
|
646
|
-
|
647
|
-
_ID = *val
|
658
|
+
module_eval <<-'.,.,120998292224012.,.,', 'ast.dr', 149
|
659
|
+
def _act_15 val
|
660
|
+
_ID, = *val
|
648
661
|
_ID.value
|
649
662
|
|
650
|
-
|
651
|
-
|
652
|
-
.,.,118754107746326.,.,
|
663
|
+
end
|
664
|
+
.,.,120998292224012.,.,
|
653
665
|
|
654
|
-
module_eval <<-'.,.,
|
655
|
-
|
656
|
-
_, _ID = *val
|
666
|
+
module_eval <<-'.,.,120998292234792.,.,', 'ast.dr', 150
|
667
|
+
def _act_16 val
|
668
|
+
_, _ID, = *val
|
657
669
|
'-' + _ID.value
|
658
670
|
|
659
|
-
|
660
|
-
|
661
|
-
.,.,11875410778315.,.,
|
671
|
+
end
|
672
|
+
.,.,120998292234792.,.,
|
662
673
|
|
663
|
-
module_eval <<-'.,.,
|
664
|
-
|
665
|
-
_ID = *val
|
674
|
+
module_eval <<-'.,.,120998292214019.,.,', 'ast.dr', 153
|
675
|
+
def _act_17 val
|
676
|
+
_ID, = *val
|
666
677
|
[ _ID.value ]
|
667
678
|
|
668
|
-
|
669
|
-
|
670
|
-
.,.,118754107752669.,.,
|
679
|
+
end
|
680
|
+
.,.,120998292214019.,.,
|
671
681
|
|
672
|
-
module_eval <<-'.,.,
|
673
|
-
|
674
|
-
_id_list, _, _ID = *val
|
682
|
+
module_eval <<-'.,.,120998292250833.,.,', 'ast.dr', 154
|
683
|
+
def _act_18 val
|
684
|
+
_id_list, _, _ID, = *val
|
675
685
|
_id_list.push _ID.value
|
676
686
|
|
677
|
-
|
678
|
-
|
679
|
-
.,.,118754107765360.,.,
|
687
|
+
end
|
688
|
+
.,.,120998292250833.,.,
|
680
689
|
|
681
|
-
module_eval <<-'.,.,
|
682
|
-
|
690
|
+
module_eval <<-'.,.,12099829221352.,.,', 'ast.dr', 157
|
691
|
+
def _act_19 val
|
683
692
|
{nil => Token['', 0]}
|
684
693
|
|
685
|
-
|
686
|
-
|
687
|
-
.,.,118754107744253.,.,
|
694
|
+
end
|
695
|
+
.,.,12099829221352.,.,
|
688
696
|
|
689
|
-
module_eval <<-'.,.,
|
690
|
-
|
691
|
-
_ACTION = *val
|
697
|
+
module_eval <<-'.,.,120998292263848.,.,', 'ast.dr', 158
|
698
|
+
def _act_20 val
|
699
|
+
_ACTION, = *val
|
692
700
|
{nil => _ACTION}
|
693
701
|
|
694
|
-
|
695
|
-
|
696
|
-
.,.,118754107754433.,.,
|
702
|
+
end
|
703
|
+
.,.,120998292263848.,.,
|
697
704
|
|
698
|
-
module_eval <<-'.,.,
|
699
|
-
|
700
|
-
_pass_action_list = *val
|
701
|
-
|
702
|
-
Hash.new(_pass_action_list).marge({nil => Token['', 0]})
|
705
|
+
module_eval <<-'.,.,12099829226375.,.,', 'ast.dr', 160
|
706
|
+
def _act_21 val
|
707
|
+
_pass_action_list, = *val
|
703
708
|
|
704
|
-
|
709
|
+
Hash[ *_pass_action_list.flatten ].merge({nil => Token['', 0]})
|
705
710
|
|
706
|
-
|
711
|
+
end
|
712
|
+
.,.,12099829226375.,.,
|
707
713
|
|
708
|
-
module_eval <<-'.,.,
|
709
|
-
|
710
|
-
_pass_action = *val
|
711
|
-
_pass_action
|
714
|
+
module_eval <<-'.,.,120998292257313.,.,', 'ast.dr', 165
|
715
|
+
def _act_22 val
|
716
|
+
_pass_action, = *val
|
717
|
+
[ _pass_action ]
|
712
718
|
|
713
|
-
|
714
|
-
|
715
|
-
.,.,118754107719437.,.,
|
719
|
+
end
|
720
|
+
.,.,120998292257313.,.,
|
716
721
|
|
717
|
-
module_eval <<-'.,.,
|
718
|
-
|
719
|
-
_pass_action_list, _pass_action = *val
|
722
|
+
module_eval <<-'.,.,120998292225817.,.,', 'ast.dr', 166
|
723
|
+
def _act_23 val
|
724
|
+
_pass_action_list, _pass_action, = *val
|
720
725
|
_pass_action_list << _pass_action
|
721
726
|
|
722
|
-
|
723
|
-
|
724
|
-
.,.,118754107742276.,.,
|
727
|
+
end
|
728
|
+
.,.,120998292225817.,.,
|
725
729
|
|
726
|
-
module_eval <<-'.,.,
|
727
|
-
|
728
|
-
_, _ID, _, _ACTION = *val
|
730
|
+
module_eval <<-'.,.,120998292244454.,.,', 'ast.dr', 170
|
731
|
+
def _act_24 val
|
732
|
+
_, _ID, _, _ACTION, = *val
|
729
733
|
[_ID.value, _ACTION]
|
730
734
|
|
731
|
-
|
732
|
-
|
733
|
-
.,.,118754107745765.,.,
|
735
|
+
end
|
736
|
+
.,.,120998292244454.,.,
|
734
737
|
|
735
738
|
end
|
736
739
|
|
737
740
|
|
738
741
|
###
|
739
|
-
###
|
742
|
+
### ASTBuilderExtension_postrhs - Part of Depager Extension (slave)
|
740
743
|
###
|
741
|
-
module
|
744
|
+
module D4ASTBuilderExtension_postrhs #:nodoc:all
|
742
745
|
end
|
743
746
|
|
744
|
-
class
|
747
|
+
class ASTBuilderExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
745
748
|
include Depager::ExtensionUtils
|
746
749
|
|
747
750
|
|
748
751
|
### Reduce Table
|
749
752
|
reduce_table = [
|
750
753
|
[ -1, 1 ],
|
751
|
-
[ 0,
|
754
|
+
[ 0, 1 ],
|
752
755
|
[ 2, 3 ],
|
753
756
|
[ 2, 4 ],
|
754
757
|
[ 3, 1 ],
|
@@ -762,6 +765,7 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
762
765
|
[ 4, 1 ],
|
763
766
|
[ 4, 1 ],
|
764
767
|
[ 4, 1 ],
|
768
|
+
[ 4, 1 ],
|
765
769
|
[ 6, 0 ],
|
766
770
|
[ 6, 1 ],
|
767
771
|
[ 5, 2 ],
|
@@ -777,16 +781,16 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
777
781
|
t2i = {
|
778
782
|
nil => 0,
|
779
783
|
false => 1,
|
780
|
-
:
|
781
|
-
|
782
|
-
"
|
783
|
-
"
|
784
|
-
|
785
|
-
:
|
786
|
-
:
|
787
|
-
:
|
788
|
-
:
|
789
|
-
:
|
784
|
+
:ID => 2,
|
785
|
+
"(" => 3,
|
786
|
+
")" => 4,
|
787
|
+
"," => 5,
|
788
|
+
:CONST => 6,
|
789
|
+
:SYMBOL => 7,
|
790
|
+
:STR => 8,
|
791
|
+
:NILNODE => 9,
|
792
|
+
:NUMBER => 10,
|
793
|
+
:NIL => 11,
|
790
794
|
:EMBED => 12,
|
791
795
|
"[" => 13,
|
792
796
|
"]" => 14,
|
@@ -797,7 +801,6 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
797
801
|
i2t = [
|
798
802
|
nil,
|
799
803
|
false,
|
800
|
-
:EG,
|
801
804
|
:ID,
|
802
805
|
"(",
|
803
806
|
")",
|
@@ -805,8 +808,9 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
805
808
|
:CONST,
|
806
809
|
:SYMBOL,
|
807
810
|
:STR,
|
808
|
-
:
|
811
|
+
:NILNODE,
|
809
812
|
:NUMBER,
|
813
|
+
:NIL,
|
810
814
|
:EMBED,
|
811
815
|
"[",
|
812
816
|
"]",
|
@@ -815,66 +819,66 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
815
819
|
]
|
816
820
|
### Action Table
|
817
821
|
action_table = [
|
818
|
-
[ nil, nil,
|
822
|
+
[ nil, nil, 6, nil, nil, nil, 7, 8, 9, 10, 11, 12, nil, 13, nil, nil, nil, ],
|
819
823
|
[ ACC, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
820
|
-
[ nil, nil, nil,
|
824
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 14, 15, ],
|
821
825
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
822
826
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
823
|
-
[ nil, nil, nil, nil, 14, nil, nil, nil, nil, nil, nil, nil, 16, nil, nil, nil, nil, ],
|
824
827
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
828
|
+
[ nil, nil, nil, 18, nil, nil, nil, nil, nil, nil, nil, nil, 17, nil, nil, nil, nil, ],
|
825
829
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
826
830
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
827
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 17, 18, ],
|
828
831
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
829
832
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
830
833
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
831
|
-
[ nil, nil, nil, 5, nil, nil, nil, 12, 3, 6, 8, 10, nil, 13, 19, nil, nil, ],
|
832
|
-
[ nil, nil, nil, 5, nil, 22, nil, 12, 3, 6, 8, 10, nil, 13, nil, nil, nil, ],
|
833
834
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
835
|
+
[ nil, nil, 6, nil, nil, nil, 7, 8, 9, 10, 11, 12, nil, 13, 19, nil, nil, ],
|
836
|
+
[ nil, nil, 6, nil, nil, nil, 7, 8, 9, 10, 11, 12, nil, 13, nil, nil, nil, ],
|
837
|
+
[ nil, nil, 6, nil, nil, nil, 7, 8, 9, 10, 11, 12, nil, 13, nil, nil, nil, ],
|
834
838
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
835
|
-
[ nil, nil, nil, 5, nil, nil, nil, 12, 3, 6, 8, 10, nil, 13, nil, nil, nil, ],
|
836
|
-
[ nil, nil, nil, 5, nil, nil, nil, 12, 3, 6, 8, 10, nil, 13, nil, nil, nil, ],
|
837
839
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
838
|
-
[ nil, nil,
|
839
|
-
[ nil, nil, nil, nil, nil, nil, 27, nil, nil, nil, nil, nil, nil, nil, 26, nil, nil, ],
|
840
|
+
[ nil, nil, 6, nil, 24, nil, 7, 8, 9, 10, 11, 12, nil, 13, nil, nil, nil, ],
|
840
841
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
841
|
-
[ nil, nil, nil, nil, nil,
|
842
|
+
[ nil, nil, nil, nil, nil, 27, nil, nil, nil, nil, nil, nil, nil, nil, 26, nil, nil, ],
|
843
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 14, 15, ],
|
844
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 14, 15, ],
|
845
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 14, 15, ],
|
842
846
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
847
|
+
[ nil, nil, nil, nil, 28, 27, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
843
848
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
849
|
+
[ nil, nil, 6, nil, nil, nil, 7, 8, 9, 10, 11, 12, nil, 13, nil, nil, nil, ],
|
844
850
|
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
845
|
-
[ nil, nil, nil,
|
846
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
|
847
|
-
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 17, 18, ],
|
851
|
+
[ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 14, 15, ],
|
848
852
|
]
|
849
853
|
### Default Reduce Table
|
850
854
|
defred_table = [
|
851
855
|
nil,
|
852
856
|
nil,
|
853
|
-
|
854
|
-
-11,
|
857
|
+
-1,
|
855
858
|
-6,
|
856
|
-
-
|
857
|
-
-12,
|
859
|
+
-7,
|
858
860
|
-8,
|
861
|
+
-16,
|
862
|
+
-10,
|
863
|
+
-11,
|
864
|
+
-12,
|
859
865
|
-13,
|
860
|
-
-1,
|
861
866
|
-14,
|
862
|
-
-
|
863
|
-
|
867
|
+
-15,
|
868
|
+
nil,
|
864
869
|
nil,
|
865
870
|
nil,
|
866
871
|
-9,
|
867
|
-
-
|
872
|
+
-17,
|
868
873
|
nil,
|
874
|
+
-18,
|
869
875
|
nil,
|
870
|
-
-17,
|
871
876
|
-4,
|
872
|
-
|
877
|
+
-20,
|
878
|
+
-21,
|
873
879
|
-2,
|
874
880
|
nil,
|
875
881
|
-19,
|
876
|
-
-20,
|
877
|
-
-18,
|
878
882
|
nil,
|
879
883
|
-3,
|
880
884
|
-5,
|
@@ -883,30 +887,30 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
883
887
|
nil,
|
884
888
|
nil,
|
885
889
|
nil,
|
886
|
-
-11,
|
887
890
|
-6,
|
891
|
+
-7,
|
892
|
+
-8,
|
888
893
|
nil,
|
894
|
+
-10,
|
895
|
+
-11,
|
889
896
|
-12,
|
890
|
-
-8,
|
891
897
|
-13,
|
892
|
-
nil,
|
893
898
|
-14,
|
894
|
-
-
|
895
|
-
|
899
|
+
-15,
|
900
|
+
nil,
|
896
901
|
nil,
|
897
902
|
nil,
|
898
903
|
-9,
|
899
|
-
-
|
904
|
+
-17,
|
905
|
+
nil,
|
906
|
+
-18,
|
900
907
|
nil,
|
901
908
|
nil,
|
902
|
-
-17,
|
903
909
|
nil,
|
904
910
|
nil,
|
905
911
|
-2,
|
906
912
|
nil,
|
907
913
|
-19,
|
908
|
-
-20,
|
909
|
-
-18,
|
910
914
|
nil,
|
911
915
|
-3,
|
912
916
|
nil,
|
@@ -933,26 +937,25 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
933
937
|
]
|
934
938
|
### Goto Table
|
935
939
|
goto_table = [
|
936
|
-
[ 1,
|
940
|
+
[ 1, 2, 4, nil, 3, 5, nil, ],
|
937
941
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
938
|
-
[ nil, 9, 11, nil, 4, 7, nil, ],
|
939
942
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
940
943
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
941
|
-
[ nil, nil, nil, nil, nil, nil, 15, ],
|
942
944
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
943
945
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
946
|
+
[ nil, nil, nil, nil, nil, nil, 16, ],
|
944
947
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
945
948
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
946
949
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
947
950
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
948
951
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
949
|
-
[ nil, 20, 11, 21, 4, 7, nil, ],
|
950
|
-
[ nil, 20, 11, 23, 4, 7, nil, ],
|
951
952
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
953
|
+
[ nil, 21, 4, 20, 3, 5, nil, ],
|
954
|
+
[ nil, 22, 4, nil, 3, 5, nil, ],
|
955
|
+
[ nil, 23, 4, nil, 3, 5, nil, ],
|
952
956
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
953
|
-
[ nil, 24, 11, nil, 4, 7, nil, ],
|
954
|
-
[ nil, 25, 11, nil, 4, 7, nil, ],
|
955
957
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
958
|
+
[ nil, 21, 4, 25, 3, 5, nil, ],
|
956
959
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
957
960
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
958
961
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
@@ -960,7 +963,8 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
960
963
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
961
964
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
962
965
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
963
|
-
[ nil,
|
966
|
+
[ nil, nil, nil, nil, nil, nil, nil, ],
|
967
|
+
[ nil, 29, 4, nil, 3, 5, nil, ],
|
964
968
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
965
969
|
[ nil, nil, nil, nil, nil, nil, nil, ],
|
966
970
|
]
|
@@ -975,11 +979,20 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
975
979
|
@g_parser = @p = p
|
976
980
|
@master = @m = master
|
977
981
|
@nparam = nparam
|
978
|
-
@dect =
|
982
|
+
@dect = D4ASTBuilderExtension_postrhs::NVAction.new(self)
|
979
983
|
init_parser
|
980
984
|
end
|
981
985
|
|
982
986
|
|
987
|
+
def do_parse?
|
988
|
+
if @line =~ /^\s*=>/
|
989
|
+
@line = $'
|
990
|
+
true
|
991
|
+
else
|
992
|
+
false
|
993
|
+
end
|
994
|
+
end
|
995
|
+
|
983
996
|
|
984
997
|
def banner
|
985
998
|
"=>... / #{@master.class.name}"
|
@@ -1007,11 +1020,6 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
1007
1020
|
yield _Token(:LL, $&)
|
1008
1021
|
|
1009
1022
|
|
1010
|
-
when /\A=>/
|
1011
|
-
@oldline = @line; @line = $'
|
1012
|
-
yield _Token(:EG, $&)
|
1013
|
-
|
1014
|
-
|
1015
1023
|
when /\A%([a-zA-Z0-9_]+)((::[a-zA-Z0-9_]+)*)/
|
1016
1024
|
@oldline = @line; @line = $'
|
1017
1025
|
yield _Token(:CONST, $1+$2)
|
@@ -1027,6 +1035,11 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
1027
1035
|
yield _Token(:NIL, $&)
|
1028
1036
|
|
1029
1037
|
|
1038
|
+
when /\ANilNode/
|
1039
|
+
@oldline = @line; @line = $'
|
1040
|
+
yield _Token(:NILNODE, $&)
|
1041
|
+
|
1042
|
+
|
1030
1043
|
when /\A[0-9]+/
|
1031
1044
|
@oldline = @line; @line = $'
|
1032
1045
|
yield _Token(:NUMBER, $&.to_i)
|
@@ -1059,14 +1072,20 @@ class ASTBuilderBaseExtension_postrhs < Depager::LALR::Basis #:nodoc:all
|
|
1059
1072
|
end while @line0 = @line = getline
|
1060
1073
|
yield nil, nil
|
1061
1074
|
end
|
1062
|
-
|
1075
|
+
def do_default
|
1076
|
+
n = master.nrules
|
1077
|
+
master.optouter <<
|
1078
|
+
master.gen_defm_code("_ast_#{n} val", "NilNode.new(basis.file.lineno)", lineno)
|
1079
|
+
master.on_reduce[n] = ":_ast_#{n}"
|
1080
|
+
end
|
1081
|
+
|
1063
1082
|
end
|
1064
1083
|
|
1065
1084
|
### Outer Code
|
1066
1085
|
|
1067
|
-
class
|
1086
|
+
class D4ASTBuilderExtension_postrhs::NVAction < Depager::LALR::Action #:nodoc:all
|
1068
1087
|
include Depager::DecoratorUtils
|
1069
|
-
|
1088
|
+
[]
|
1070
1089
|
on_reduce = [
|
1071
1090
|
nil,
|
1072
1091
|
:_act_0,
|
@@ -1089,6 +1108,7 @@ class D4ASTBuilderBaseExtension_postrhs::NVAction < Depager::LALR::Action #:nodo
|
|
1089
1108
|
:_act_17,
|
1090
1109
|
:_act_18,
|
1091
1110
|
:_act_19,
|
1111
|
+
:_act_20,
|
1092
1112
|
|
1093
1113
|
]
|
1094
1114
|
Tables = [on_reduce]
|
@@ -1099,31 +1119,29 @@ class D4ASTBuilderBaseExtension_postrhs::NVAction < Depager::LALR::Action #:nodo
|
|
1099
1119
|
end
|
1100
1120
|
|
1101
1121
|
|
1102
|
-
module_eval <<-'.,.,
|
1103
|
-
|
1104
|
-
|
1122
|
+
module_eval <<-'.,.,120998292239108.,.,', 'ast.dr', 207
|
1123
|
+
def _act_0 val
|
1124
|
+
_fnl, = *val
|
1105
1125
|
|
1106
1126
|
n = master.nrules
|
1107
1127
|
master.optouter <<
|
1108
|
-
master.gen_defm_code("_ast_#{n} val", _fnl,
|
1128
|
+
master.gen_defm_code("_ast_#{n} val", _fnl, basis.file.lineno)
|
1109
1129
|
master.on_reduce[n] = ":_ast_#{n}"
|
1110
1130
|
|
1111
|
-
|
1112
|
-
|
1113
|
-
.,.,118754107714013.,.,
|
1131
|
+
end
|
1132
|
+
.,.,120998292239108.,.,
|
1114
1133
|
|
1115
|
-
module_eval <<-'.,.,
|
1116
|
-
|
1117
|
-
_ID, _, _ = *val
|
1134
|
+
module_eval <<-'.,.,120998292255540.,.,', 'ast.dr', 215
|
1135
|
+
def _act_1 val
|
1136
|
+
_ID, _, _, = *val
|
1118
1137
|
"Node_#{_ID.value}.new(basis.file.lineno)"
|
1119
1138
|
|
1120
|
-
|
1121
|
-
|
1122
|
-
.,.,118754107760130.,.,
|
1139
|
+
end
|
1140
|
+
.,.,120998292255540.,.,
|
1123
1141
|
|
1124
|
-
module_eval <<-'.,.,
|
1125
|
-
|
1126
|
-
_ID, _, _fnlpair, _ = *val
|
1142
|
+
module_eval <<-'.,.,120998292239123.,.,', 'ast.dr', 217
|
1143
|
+
def _act_2 val
|
1144
|
+
_ID, _, _fnlpair, _, = *val
|
1127
1145
|
|
1128
1146
|
if g_parser.rhs.size > 0
|
1129
1147
|
"Node_#{_ID.value}.new(val[0].lineno, #{_fnlpair.join(', ')})"
|
@@ -1131,143 +1149,136 @@ module_eval <<-'.,.,118754107725185.,.,', 'ast_base.dr', 180
|
|
1131
1149
|
"Node_#{_ID.value}.new(basis.file.lineno, #{_fnlpair.join(', ')})"
|
1132
1150
|
end
|
1133
1151
|
|
1134
|
-
|
1135
|
-
|
1136
|
-
.,.,118754107725185.,.,
|
1152
|
+
end
|
1153
|
+
.,.,120998292239123.,.,
|
1137
1154
|
|
1138
|
-
module_eval <<-'.,.,
|
1139
|
-
|
1140
|
-
_fnl = *val
|
1155
|
+
module_eval <<-'.,.,120998292218775.,.,', 'ast.dr', 226
|
1156
|
+
def _act_3 val
|
1157
|
+
_fnl, = *val
|
1141
1158
|
[_fnl]
|
1142
1159
|
|
1143
|
-
|
1144
|
-
|
1145
|
-
.,.,118754107718708.,.,
|
1160
|
+
end
|
1161
|
+
.,.,120998292218775.,.,
|
1146
1162
|
|
1147
|
-
module_eval <<-'.,.,
|
1148
|
-
|
1149
|
-
_fnlpair, _, _fnl = *val
|
1163
|
+
module_eval <<-'.,.,120998292219935.,.,', 'ast.dr', 227
|
1164
|
+
def _act_4 val
|
1165
|
+
_fnlpair, _, _fnl, = *val
|
1150
1166
|
_fnlpair << _fnl
|
1151
1167
|
|
1152
|
-
|
1153
|
-
|
1154
|
-
.,.,118754107758988.,.,
|
1168
|
+
end
|
1169
|
+
.,.,120998292219935.,.,
|
1155
1170
|
|
1156
|
-
module_eval <<-'.,.,
|
1157
|
-
|
1158
|
-
_fact = *val
|
1171
|
+
module_eval <<-'.,.,120998292237800.,.,', 'ast.dr', 230
|
1172
|
+
def _act_5 val
|
1173
|
+
_fact, = *val
|
1159
1174
|
_fact
|
1160
1175
|
|
1161
|
-
|
1162
|
-
|
1163
|
-
.,.,118754107723770.,.,
|
1176
|
+
end
|
1177
|
+
.,.,120998292237800.,.,
|
1164
1178
|
|
1165
|
-
module_eval <<-'.,.,
|
1166
|
-
|
1167
|
-
_node = *val
|
1179
|
+
module_eval <<-'.,.,12099829227551.,.,', 'ast.dr', 231
|
1180
|
+
def _act_6 val
|
1181
|
+
_node, = *val
|
1168
1182
|
_node
|
1169
1183
|
|
1170
|
-
|
1171
|
-
|
1172
|
-
.,.,118754107750177.,.,
|
1184
|
+
end
|
1185
|
+
.,.,12099829227551.,.,
|
1173
1186
|
|
1174
|
-
module_eval <<-'.,.,
|
1175
|
-
|
1176
|
-
_list = *val
|
1187
|
+
module_eval <<-'.,.,120998292244492.,.,', 'ast.dr', 232
|
1188
|
+
def _act_7 val
|
1189
|
+
_list, = *val
|
1177
1190
|
_list
|
1178
1191
|
|
1179
|
-
|
1180
|
-
|
1181
|
-
.,.,118754107731712.,.,
|
1192
|
+
end
|
1193
|
+
.,.,120998292244492.,.,
|
1182
1194
|
|
1183
|
-
module_eval <<-'.,.,
|
1184
|
-
|
1185
|
-
_ID, _opt_embed = *val
|
1195
|
+
module_eval <<-'.,.,120998292242233.,.,', 'ast.dr', 236
|
1196
|
+
def _act_8 val
|
1197
|
+
_ID, _opt_embed, = *val
|
1186
1198
|
|
1187
|
-
unless i = g_parser.name_to_rhs_index(
|
1188
|
-
warn "#{g_parser.lineno}: ?#{
|
1199
|
+
unless i = g_parser.name_to_rhs_index(_ID.value)
|
1200
|
+
warn "#{g_parser.lineno}: ?#{_ID.value}"
|
1189
1201
|
raise
|
1190
1202
|
end
|
1191
1203
|
"val[#{i}]#{val[1]}"
|
1192
1204
|
|
1193
|
-
|
1194
|
-
|
1195
|
-
.,.,118754107736385.,.,
|
1205
|
+
end
|
1206
|
+
.,.,120998292242233.,.,
|
1196
1207
|
|
1197
|
-
module_eval <<-'.,.,
|
1198
|
-
|
1199
|
-
_CONST = *val
|
1208
|
+
module_eval <<-'.,.,120998292219954.,.,', 'ast.dr', 243
|
1209
|
+
def _act_9 val
|
1210
|
+
_CONST, = *val
|
1200
1211
|
"Depager::Token[#{_CONST.value}]"
|
1201
1212
|
|
1202
|
-
|
1203
|
-
|
1204
|
-
.,.,118754107744168.,.,
|
1213
|
+
end
|
1214
|
+
.,.,120998292219954.,.,
|
1205
1215
|
|
1206
|
-
module_eval <<-'.,.,
|
1207
|
-
|
1208
|
-
_SYMBOL = *val
|
1216
|
+
module_eval <<-'.,.,120998292251058.,.,', 'ast.dr', 244
|
1217
|
+
def _act_10 val
|
1218
|
+
_SYMBOL, = *val
|
1209
1219
|
"Depager::Token[#{_SYMBOL.value}]"
|
1210
1220
|
|
1211
|
-
|
1212
|
-
|
1213
|
-
.,.,118754107728765.,.,
|
1221
|
+
end
|
1222
|
+
.,.,120998292251058.,.,
|
1214
1223
|
|
1215
|
-
module_eval <<-'.,.,
|
1216
|
-
|
1217
|
-
_STR = *val
|
1224
|
+
module_eval <<-'.,.,120998292253260.,.,', 'ast.dr', 245
|
1225
|
+
def _act_11 val
|
1226
|
+
_STR, = *val
|
1218
1227
|
"Depager::Token['#{_STR.value}']"
|
1219
1228
|
|
1220
|
-
|
1221
|
-
|
1222
|
-
.,.,118754107732274.,.,
|
1229
|
+
end
|
1230
|
+
.,.,120998292253260.,.,
|
1223
1231
|
|
1224
|
-
module_eval <<-'.,.,
|
1225
|
-
|
1226
|
-
|
1227
|
-
"
|
1232
|
+
module_eval <<-'.,.,120998292210497.,.,', 'ast.dr', 246
|
1233
|
+
def _act_12 val
|
1234
|
+
_NILNODE, = *val
|
1235
|
+
"NilNode.new(basis.file.lineno)"
|
1228
1236
|
|
1229
|
-
|
1230
|
-
|
1231
|
-
.,.,11875410774520.,.,
|
1237
|
+
end
|
1238
|
+
.,.,120998292210497.,.,
|
1232
1239
|
|
1233
|
-
module_eval <<-'.,.,
|
1234
|
-
|
1235
|
-
_NUMBER = *val
|
1240
|
+
module_eval <<-'.,.,120998292239142.,.,', 'ast.dr', 247
|
1241
|
+
def _act_13 val
|
1242
|
+
_NUMBER, = *val
|
1236
1243
|
"Depager::Token[#{_NUMBER.value}]"
|
1237
1244
|
|
1238
|
-
|
1245
|
+
end
|
1246
|
+
.,.,120998292239142.,.,
|
1247
|
+
|
1248
|
+
module_eval <<-'.,.,120998292241721.,.,', 'ast.dr', 248
|
1249
|
+
def _act_14 val
|
1250
|
+
_NIL, = *val
|
1251
|
+
"nil"
|
1239
1252
|
|
1240
|
-
|
1253
|
+
end
|
1254
|
+
.,.,120998292241721.,.,
|
1241
1255
|
|
1242
|
-
module_eval <<-'.,.,
|
1243
|
-
|
1256
|
+
module_eval <<-'.,.,120998292222707.,.,', 'ast.dr', 251
|
1257
|
+
def _act_15 val
|
1244
1258
|
''
|
1245
1259
|
|
1246
|
-
|
1247
|
-
|
1248
|
-
.,.,118754107736080.,.,
|
1260
|
+
end
|
1261
|
+
.,.,120998292222707.,.,
|
1249
1262
|
|
1250
|
-
module_eval <<-'.,.,
|
1251
|
-
|
1252
|
-
_EMBED = *val
|
1263
|
+
module_eval <<-'.,.,120998292213288.,.,', 'ast.dr', 252
|
1264
|
+
def _act_16 val
|
1265
|
+
_EMBED, = *val
|
1253
1266
|
_EMBED.value
|
1254
1267
|
|
1255
|
-
|
1256
|
-
|
1257
|
-
.,.,118754107755265.,.,
|
1268
|
+
end
|
1269
|
+
.,.,120998292213288.,.,
|
1258
1270
|
|
1259
|
-
module_eval <<-'.,.,
|
1260
|
-
|
1261
|
-
_, _ = *val
|
1271
|
+
module_eval <<-'.,.,120998292244551.,.,', 'ast.dr', 255
|
1272
|
+
def _act_17 val
|
1273
|
+
_, _, = *val
|
1262
1274
|
"NodeList.new(basis.file.lineno, [])"
|
1263
1275
|
|
1264
|
-
|
1265
|
-
|
1266
|
-
.,.,11875410774449.,.,
|
1276
|
+
end
|
1277
|
+
.,.,120998292244551.,.,
|
1267
1278
|
|
1268
|
-
module_eval <<-'.,.,
|
1269
|
-
|
1270
|
-
_, _fnlpair, _ = *val
|
1279
|
+
module_eval <<-'.,.,120998292244197.,.,', 'ast.dr', 257
|
1280
|
+
def _act_18 val
|
1281
|
+
_, _fnlpair, _, = *val
|
1271
1282
|
|
1272
1283
|
if g_parser.rhs.size > 0
|
1273
1284
|
"NodeList.new(val[0].lineno, [#{_fnlpair.join(', ')}])"
|
@@ -1275,27 +1286,24 @@ module_eval <<-'.,.,118754107747720.,.,', 'ast_base.dr', 219
|
|
1275
1286
|
"NodeList.new(basis.file.lineno, #{_fnlpair.join(', ')})"
|
1276
1287
|
end
|
1277
1288
|
|
1278
|
-
|
1279
|
-
|
1280
|
-
.,.,118754107747720.,.,
|
1289
|
+
end
|
1290
|
+
.,.,120998292244197.,.,
|
1281
1291
|
|
1282
|
-
module_eval <<-'.,.,
|
1283
|
-
|
1284
|
-
_l, _LL, _r = *val
|
1292
|
+
module_eval <<-'.,.,120998292253403.,.,', 'ast.dr', 264
|
1293
|
+
def _act_19 val
|
1294
|
+
_l, _LL, _r, = *val
|
1285
1295
|
"#{_l}.push(#{_r})"
|
1286
1296
|
|
1287
|
-
|
1288
|
-
|
1289
|
-
.,.,118754107749519.,.,
|
1297
|
+
end
|
1298
|
+
.,.,120998292253403.,.,
|
1290
1299
|
|
1291
|
-
module_eval <<-'.,.,
|
1292
|
-
|
1293
|
-
_l, _, _r = *val
|
1300
|
+
module_eval <<-'.,.,12099829222596.,.,', 'ast.dr', 265
|
1301
|
+
def _act_20 val
|
1302
|
+
_l, _, _r, = *val
|
1294
1303
|
"#{_l}.concat(#{_r})"
|
1295
1304
|
|
1296
|
-
|
1297
|
-
|
1298
|
-
.,.,118754107726284.,.,
|
1305
|
+
end
|
1306
|
+
.,.,12099829222596.,.,
|
1299
1307
|
|
1300
1308
|
end
|
1301
1309
|
|