depager 0.2.3 → 0.3.0.b20250423

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 (106) hide show
  1. checksums.yaml +7 -0
  2. data/.rubocop.yml +44 -0
  3. data/.simplecov +5 -0
  4. data/Gemfile +12 -0
  5. data/LICENSE.gpl +339 -0
  6. data/Manifest.txt +73 -0
  7. data/README.en +7 -21
  8. data/README.ja +19 -99
  9. data/Rakefile +31 -0
  10. data/bin/depager +7 -45
  11. data/examples/action_pl0d/pl0d.action.dr +421 -0
  12. data/examples/action_pl0d/test.pl0ds +48 -0
  13. data/examples/c89/c89.dr +493 -496
  14. data/examples/c89/test.c89 +10 -10
  15. data/examples/extension/astdf.rb +9 -0
  16. data/examples/extension/atree.dr +55 -0
  17. data/examples/{sample_calc → extension}/calc.atree.dr +42 -43
  18. data/examples/{sample_calc/calc.action.dr → extension/calc.simple_action.dr} +33 -33
  19. data/examples/extension/paction.dr +16 -15
  20. data/examples/extension/pactiontest.dr +14 -14
  21. data/examples/extension/simple_action.rb +46 -0
  22. data/examples/pl0d/pl0ds.dr +337 -334
  23. data/examples/pl0d/test.pl0ds +33 -33
  24. data/examples/rie_calc/calc.rie.dr +57 -0
  25. data/examples/rie_calc/test.calc +4 -0
  26. data/examples/rie_dcuse/dcuse.rie.dr +71 -0
  27. data/examples/rie_dcuse/test.dcuse +1 -0
  28. data/examples/rie_pl0/orig_ex/exerrdg.pl0 +44 -0
  29. data/examples/rie_pl0/orig_ex/exerrm.pl0 +19 -0
  30. data/examples/rie_pl0/orig_ex/exerrmre.pl0 +20 -0
  31. data/examples/rie_pl0/orig_ex/exerrtok.pl0 +18 -0
  32. data/examples/rie_pl0/orig_ex/exmdg.pl0 +40 -0
  33. data/examples/rie_pl0/orig_ex/exmdgwwl.pl0 +43 -0
  34. data/examples/rie_pl0/orig_ex/exmrw.pl0 +22 -0
  35. data/examples/rie_pl0/orig_ex/exmwwl.pl0 +18 -0
  36. data/examples/rie_pl0/orig_ex/exnorw.pl0 +17 -0
  37. data/examples/rie_pl0/pl0.rie.dr +450 -0
  38. data/examples/rie_pl0/test.pl0 +10 -0
  39. data/examples/slex_test/divreg.slex.dr +29 -29
  40. data/examples/slex_test/ljoin.slex.dr +36 -36
  41. data/examples/slex_test/test.divreg +1 -1
  42. data/examples/slex_test/test.ljoin +3 -3
  43. data/examples/{sample_calc/calc.nvaction.dr → tiny_calc/calc.action.dr} +33 -33
  44. data/examples/{sample_calc → tiny_calc}/calc.ast.action.dr +76 -66
  45. data/examples/{sample_calc → tiny_calc}/calc.ast.dr +67 -55
  46. data/examples/tiny_calc/calc.cst.dr +50 -0
  47. data/examples/{sample_calc → tiny_calc}/calc.dr +43 -43
  48. data/examples/{sample_calc → tiny_calc}/calc.lex.dr +29 -29
  49. data/examples/{sample_calc/calc_prec.nvaction.dr → tiny_calc/calc_prec.action.dr} +31 -31
  50. data/lib/depager/cli.rb +44 -0
  51. data/lib/depager/grammar.rb +253 -291
  52. data/lib/depager/lr.rb +589 -579
  53. data/lib/depager/parser.rb +269 -277
  54. data/lib/depager/plugins/_rie_debug.rb +63 -0
  55. data/lib/depager/plugins/action.rb +47 -0
  56. data/lib/depager/plugins/ast.dr +367 -0
  57. data/lib/depager/plugins/ast.rb +1329 -0
  58. data/lib/depager/{ruby/plugins → plugins}/cst.dr +174 -180
  59. data/lib/depager/plugins/cst.rb +591 -0
  60. data/lib/depager/{ruby/plugins → plugins}/lex.dr +85 -89
  61. data/lib/depager/plugins/lex.rb +313 -0
  62. data/lib/depager/plugins/rie.dr +725 -0
  63. data/lib/depager/plugins/rie.rb +1614 -0
  64. data/lib/depager/{ruby/plugins → plugins}/slex.dr +201 -200
  65. data/lib/depager/plugins/slex.rb +769 -0
  66. data/lib/depager/plugins/srp.rb +46 -0
  67. data/lib/depager/ruby/templates/extension_lalr_master.erb +40 -51
  68. data/lib/depager/ruby/templates/extension_lalr_slave.erb +113 -107
  69. data/lib/depager/ruby/templates/single_lalr_parser.erb +124 -117
  70. data/lib/depager/utils.rb +158 -318
  71. data/lib/depager/version.rb +3 -3
  72. data/lib/depager.rb +572 -670
  73. metadata +77 -80
  74. data/ChangeLog +0 -16
  75. data/data/depager/pre-setup.rb +0 -3
  76. data/examples/c89/c89.tab.rb +0 -7127
  77. data/examples/pl0d/pl0ds.tab.rb +0 -2698
  78. data/examples/sample_calc/calc.action.tab.rb +0 -457
  79. data/examples/sample_calc/calc.ast.action.tab.rb +0 -749
  80. data/examples/sample_calc/calc.ast.tab.rb +0 -665
  81. data/examples/sample_calc/calc.astdf.dr +0 -54
  82. data/examples/sample_calc/calc.astdf.tab.rb +0 -672
  83. data/examples/sample_calc/calc.atree.tab.rb +0 -451
  84. data/examples/sample_calc/calc.cst.dr +0 -45
  85. data/examples/sample_calc/calc.cst.tab.rb +0 -644
  86. data/examples/sample_calc/calc.lex.tab.rb +0 -374
  87. data/examples/sample_calc/calc.nvaction.tab.rb +0 -465
  88. data/examples/sample_calc/calc.tab.rb +0 -365
  89. data/examples/sample_calc/calc_prec.nvaction.tab.rb +0 -431
  90. data/examples/slex_test/divreg.slex.tab.rb +0 -303
  91. data/examples/slex_test/ljoin.slex.tab.rb +0 -370
  92. data/lib/depager/ruby/plugins/_ast_tmpl.rb +0 -73
  93. data/lib/depager/ruby/plugins/action.rb +0 -43
  94. data/lib/depager/ruby/plugins/ast.dr +0 -269
  95. data/lib/depager/ruby/plugins/ast.rb +0 -1308
  96. data/lib/depager/ruby/plugins/astdf.rb +0 -6
  97. data/lib/depager/ruby/plugins/atree.dr +0 -55
  98. data/lib/depager/ruby/plugins/atree.rb +0 -347
  99. data/lib/depager/ruby/plugins/cst.rb +0 -626
  100. data/lib/depager/ruby/plugins/lex.rb +0 -336
  101. data/lib/depager/ruby/plugins/nvaction.rb +0 -19
  102. data/lib/depager/ruby/plugins/slex.rb +0 -817
  103. data/lib/depager/ruby/plugins/srp.rb +0 -51
  104. data/lib/depager/ruby/templates/simple.erb +0 -23
  105. data/setup.rb +0 -1585
  106. /data/examples/{sample_calc → tiny_calc}/test.calc +0 -0
@@ -0,0 +1,1614 @@
1
+ ###
2
+ ### Depager::RieExtension - Depager Extension (master)
3
+ ###
4
+ require 'depager/parser.rb'
5
+
6
+
7
+ module Depager ; end
8
+
9
+ class Depager::RieExtension < Depager::Extension
10
+
11
+ def initialize
12
+ super
13
+ @master = self
14
+ @slaves = []
15
+ end
16
+
17
+ def extension_registered g_parser
18
+ super g_parser
19
+
20
+ @slaves << Depager::RieExtension::PostLhs0::Parser.new(g_parser, self)
21
+ g_parser.hooks[:post_lhs].push [@slaves.last, :do_parse]
22
+ @slaves << Depager::RieExtension::PostRhs1::Parser.new(g_parser, self)
23
+ g_parser.hooks[:post_rhs].push [@slaves.last, :do_parse]
24
+ end
25
+
26
+ module_eval <<'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 7
27
+ require "pp"
28
+
29
+ module Nodes
30
+ N_THREAD = Struct.new :lineno, :targets, :excepts
31
+ N_TRANSFER = Struct.new :lineno, :targets, :excepts
32
+ N_EXCEPT = Struct.new :lineno, :let_or_ids
33
+ N_LET = Struct.new :lineno, :atoc, :expr, :state
34
+ N_ACTION = Struct.new :lineno, :expr
35
+ N_ATOC = Struct.new :lineno, :sym_name, :attr_name, :rx
36
+ end
37
+ include Nodes
38
+
39
+ begin
40
+ require 'depager/plugins/_rie_debug.rb' if Depager.debug_mode?
41
+ rescue LoadError
42
+ end
43
+
44
+ attr_accessor :action_code, :on_reduce, :semantics, :attributes, :ecs
45
+ attr_reader :grammar
46
+
47
+ def init_extension
48
+ @action_code = ''
49
+ @on_reduce = []
50
+ @on_state = []
51
+ @attributes = []
52
+ @semantics = [[]]
53
+ @locals = [{}]
54
+ @ecs = {}
55
+ if Depager.debug_mode?
56
+ path = g_parser.file == $stdin ? "stdin" : g_parser.file.path
57
+ @debug_output_path = "#{path}.rie_debug.output"
58
+ File.write @debug_output_path, ""
59
+ end
60
+ end
61
+
62
+ def term_extension
63
+ $grammar = @grammar = g_parser.table.grammar
64
+ expand_short_hand_notation
65
+ error_exit_if_error_pending
66
+
67
+ check_lattr
68
+ error_exit_if_error_pending
69
+ debug_info "locals:\n#{@locals.pretty_inspect}"
70
+
71
+ generate_action
72
+ g_parser.outer_code << generate_rie_decorator_code(@on_reduce, @on_state, @action_code)
73
+ end
74
+
75
+ def expand_short_hand_notation
76
+ semantics = []
77
+ @semantics.each_with_index do |rule_semantics, x|
78
+ res = []
79
+ (rule_semantics || []).each do |semantic|
80
+ case semantic
81
+ when N_TRANSFER ; expand_transfer res, semantic, grammar[x]
82
+ when N_THREAD ; expand_thread res, semantic, grammar[x]
83
+ else res << semantic
84
+ end
85
+ end
86
+ semantics << res
87
+ end
88
+ @semantics = semantics
89
+ end
90
+
91
+ def expand_transfer res, transfer, rule
92
+ lineno = transfer.lineno
93
+ transfer.targets.each do |attr_name|
94
+ unless @attributes[rule.lhs].include?(attr_name)
95
+ pending_error "#{attr_name} is not lhs attribute.", lineno
96
+ next
97
+ end
98
+ used = false
99
+ rule.rhs.each_with_index do |rsym, i|
100
+ next unless grammar.nonterm? rsym
101
+
102
+ rname = rule.rhs_names[i]
103
+ rattrs = @attributes[rsym] || []
104
+ next if !rattrs.include?(attr_name) || transfer.excepts.find do |e|
105
+ rname == e.sym_name and rattrs.include?(e.attr_name)
106
+ end
107
+ if attr_name[0] == ?_ # inherited attr
108
+ res << N_LET[lineno, N_ATOC[lineno, rname, attr_name, rule.n],
109
+ [N_ATOC[lineno, '$', attr_name, rule.n]]]
110
+ used = true
111
+ else
112
+ if used
113
+ pending_error "transfer `$.#{attr_name}' has too many source."
114
+ break
115
+ end
116
+ res << N_LET[lineno, N_ATOC[lineno, '$', attr_name, rule.n],
117
+ [N_ATOC[lineno, rname, attr_name, rule.n]]]
118
+ used = true
119
+ end
120
+ end
121
+ unless used
122
+ pending_error "no rhs symbol have attribute `#{attr_name}'", lineno
123
+ end
124
+ end
125
+ end
126
+
127
+ def expand_thread res, thread, rule
128
+ lineno, excepts = thread.lineno, thread.excepts.dup
129
+ thread.targets.each do |syn_name|
130
+ inh_name = '_' + syn_name
131
+ from, used = nil, false
132
+
133
+ lname = rule.lhs_name
134
+ lattrs = @attributes[rule.lhs]
135
+
136
+ if lattrs.include?(inh_name)
137
+ from = N_ATOC[lineno, '$', inh_name, rule.n]
138
+ end
139
+ rule.rhs.each_with_index do |rsym, i|
140
+ rname = rule.rhs_names[i]
141
+ rattrs = @attributes[rsym] || []
142
+
143
+ if from and rattrs.include? inh_name and
144
+ not excepts.find{|e| rname == e.sym_name && rattrs.include?(e.attr_name) }
145
+ res << N_LET[lineno, N_ATOC[lineno, rname, inh_name, rule.n], [from]]
146
+ used = true
147
+ end
148
+ if rattrs.include? syn_name
149
+ from = N_ATOC[lineno, rname, syn_name, rule.n]
150
+ end
151
+ end
152
+ if from and lattrs.include?(syn_name) and
153
+ not excepts.find{|e| lname == e.sym_name && lattrs.include?(e.attr_name) }
154
+ res << N_LET[lineno, N_ATOC[lineno, '$', syn_name, rule.n], [from]]
155
+ used = true
156
+ end
157
+ unless used
158
+ pending_error "no rhs symbol have attribute `#{syn_name}'", lineno
159
+ end
160
+ end
161
+ end
162
+
163
+ def check_lattr
164
+ @inhs_of_nonterms = []
165
+ @semantics.each_with_index do |rule_semantics, x|
166
+ rule = grammar[x]
167
+ assigned = {}
168
+ locals = @locals[rule.n] = {}
169
+ rule_semantics.each do |semantic|
170
+ semantic.is_a? N_LET and check_lattr_let semantic, rule, locals, assigned
171
+ end
172
+
173
+ next if x == 0
174
+ lineno = rule_semantics.last.lineno rescue 0
175
+ @attributes[rule.lhs].each do |a|
176
+ if a[0] != ?_ and not assigned[['$', a]]
177
+ pending_error "attribute `$.#{a}' is not assigned.", lineno
178
+ end
179
+ end
180
+ rule.rhs.each_with_index do |rsym, y|
181
+ next unless grammar.nonterm? rsym
182
+ rname = rule.rhs_names[y]
183
+ @attributes[rsym].each do |a|
184
+ if a[0] == ?_ and not assigned[[rname, a]]
185
+ pending_error "attribute `#{rname}.#{a}' is not assigned.", lineno
186
+ end
187
+ end
188
+ end
189
+ end
190
+ end
191
+
192
+ def check_lattr_let let, rule, locals, assigned
193
+ lineno = let.lineno
194
+ attr_name = let.atoc.attr_name
195
+ sym_name = let.atoc.sym_name
196
+
197
+ # left hand side of let
198
+ unless valid_atoc? let.atoc
199
+ pending_error "invalid attribute occurrence `#{sym_name}.#{attr_name}'.", lineno
200
+ return
201
+ end
202
+ if let.atoc.sym_name == '$' and inh_atoc?(let.atoc)
203
+ pending_error "cannot assign `$.#{attr_name}'(LHS INH).", lineno
204
+ return
205
+ elsif let.atoc.sym_name != '$' and syn_atoc?(let.atoc)
206
+ pending_error "cannot assign `#{sym_name}.#{attr_name}'(RHS SYN).", lineno
207
+ return
208
+ end
209
+ if local_atoc?(let.atoc)
210
+ if locals[attr_name]
211
+ warning "local attributes `#{attr_name}' is reassigned.", lineno
212
+ end
213
+ locals[attr_name] = 0
214
+ else
215
+ if assigned[[sym_name, attr_name]]
216
+ warning "attributes `#{sym_name}.#{attr_name}' is reassined.", lineno
217
+ else
218
+ assigned[[sym_name, attr_name]] = true
219
+ end
220
+ end
221
+
222
+ # right hand side of let
223
+ let.expr.find_all{|i| i.is_a? N_ATOC }.each do |expr_atoc|
224
+ unless valid_atoc? expr_atoc
225
+ next unless valid_atoc_name? expr_atoc # it is not atoc
226
+ pending_error "invalid attribute occurrence"<<
227
+ " `#{expr_atoc.sym_name}.#{expr_atoc.attr_name}'.", lineno
228
+ next
229
+ end
230
+ if expr_atoc.sym_name == '$' and syn_atoc?(expr_atoc)
231
+ pending_error "cannot refer `$.#{expr_atoc.attr_name}'(LHS SYN).", lineno
232
+ next
233
+ elsif expr_atoc.sym_name != '$' and inh_atoc?(expr_atoc)
234
+ pending_error "cannot refer `#{expr_atoc.sym_name}." <<
235
+ "#{expr_atoc.attr_name}'(RHS INH).", lineno
236
+ next
237
+ end
238
+ if local_atoc?(let.atoc)
239
+ if local_atoc?(expr_atoc) # local<-local
240
+ n = locals[expr_atoc.attr_name]
241
+ elsif syn_atoc?(expr_atoc) # local<-rsym.syn
242
+ n = rhs_index(expr_atoc)+1
243
+ else # local<-$.inh
244
+ n = 0
245
+ end
246
+ locals[attr_name] = n if locals[attr_name] < n
247
+ elsif sym_name != '$' and local_atoc?(expr_atoc) and # rhs<-local
248
+ rhs_index(let.atoc) <= locals[expr_atoc.attr_name]
249
+ pending_error "L-attribute violation.", lineno
250
+ next
251
+ elsif sym_name != '$' and expr_atoc.sym_name != '$' and # rhs<-rhs
252
+ rhs_index(let.atoc) <= rhs_index(expr_atoc)
253
+ pending_error "L-attribute violation.", lineno
254
+ next
255
+ end
256
+ end
257
+ end
258
+
259
+ def generate_action
260
+ # Actions on state change.
261
+ g_parser.table.states.each_with_index do |state, x|
262
+ actions = [ ]
263
+ inhs, locals = check_state_uniqueness(state)
264
+ inhs.each do |key, exprs| ; sym, attr_name = key
265
+ atoc = N_ATOC[0, "%#{sym}", attr_name]
266
+ actions << node_to_code(N_LET[0, atoc, exprs], state)
267
+ end
268
+ locals.each do |rx, attr_name, exprs|
269
+ atoc = N_ATOC[0, nil, attr_name, rx]
270
+ actions << node_to_code(N_LET[0, atoc, exprs], state)
271
+ end
272
+ unless actions.empty?
273
+ @action_code << "def _rie_state_#{x}\n #{actions.join("\n ")}\nend\n"
274
+ @on_state[x] = ":_rie_state_#{x}"
275
+ end
276
+ end
277
+
278
+ # Actions on reduce
279
+ @semantics.each_with_index do |rule_semantics, x|
280
+ actions = [ ]
281
+ rule = grammar[x]
282
+ rule_semantics.each do |semantic|
283
+ if semantic.is_a?(N_LET)
284
+ next if inh_atoc?(semantic.atoc)
285
+ next if local_atoc?(semantic.atoc) and not
286
+ @locals[x].find{|k,v| k == semantic.atoc.attr_name && v == rule.rhs.size }
287
+ end
288
+ code = node_to_code(semantic)
289
+ actions << code
290
+ end
291
+ unless actions.empty?
292
+ @action_code << "def _rie_reduce_#{x}\n #{actions.join("\n ")}\nend\n"
293
+ @on_reduce[x] = ":_rie_reduce_#{x}"
294
+ end
295
+ end
296
+ end
297
+
298
+ def node_to_code node, state=nil
299
+ case node
300
+ when N_LET
301
+ node_to_code(node.atoc, state) +" = "+
302
+ node_to_code(N_ACTION[0, node.expr], state)
303
+ when N_ACTION
304
+ node.expr.inject('') do |r, i|
305
+ r << (i.is_a?(N_ATOC) ? node_to_code(i, state) :
306
+ i.match(/^\s*[\{\[\(]$/) ? i : " #{i}")
307
+ end
308
+ when N_ATOC
309
+ return " #{node.sym_name}.#{node.attr_name}" unless valid_atoc? node
310
+ dot = 0
311
+ if state and item = state.closure.find{|i| i.rule.n == node.rx }
312
+ dot = item.n
313
+ elsif node.rx
314
+ dot = grammar[node.rx].rhs.size
315
+ end
316
+ if grammar.term? atoc_to_sym(node)
317
+ x = rhs_index(node) - dot
318
+ " _sstack(#{x}).syn.#{node.attr_name}"
319
+ elsif local_atoc? node
320
+ x = -dot
321
+ " _sstack(#{x-1}).local['#{node.attr_name}@#{node.rx}']"
322
+ elsif inh_atoc? node
323
+ # NEVER ASN LHS($).INH
324
+ if node.sym_name =~ /^%/ # ASN RHS.INH
325
+ x, sym = 0, $'
326
+ else # REF LHS($).INH / RHS.INH
327
+ x, sym = (rhs_index(node) || 0) - dot, atoc_to_sym(node)
328
+ end
329
+ ec = @ecs[[sym, node.attr_name]]
330
+ " _sstack(#{x-1}).inh['#{ec || sym}.#{node.attr_name}']"
331
+ else # syn_atoc?
332
+ # NEVER ASN RHS.SYN
333
+ if node.sym_name == '$' # ASN/REF LHS($).SYN
334
+ " @_rie_reduce_syn['#{node.attr_name}']"
335
+ else # REF RHS.SYN
336
+ x = rhs_index(node) - dot
337
+ " _sstack(#{x}).syn['#{node.attr_name}']"
338
+ end
339
+ end
340
+ else ; raise "cannot happen(#{node.inspect})."
341
+ end
342
+ rescue ; warn node.pretty_inspect ; raise
343
+ end
344
+
345
+ def check_state_uniqueness state
346
+ inhs, ec_inhs, locals = {}, {}, []
347
+ state.closure.each do |item|
348
+ rule = item.rule
349
+ @semantics[rule.n].each do |let|
350
+ next if !let.is_a?(N_LET)
351
+ next if item.n == rule.rhs.size
352
+ if local_atoc?(let.atoc)
353
+ @locals[rule.n].find{|k, v| k == let.atoc.attr_name && v == item.n } and
354
+ locals << [rule.n, let.atoc.attr_name, let.expr]
355
+ next
356
+ end
357
+ next if syn_atoc?(let.atoc) or rhs_index(let.atoc) != item.n
358
+
359
+ # ok, atoc is A._inh(B -> alpa _ A beta). set E_state(atoc).
360
+ attr_name = let.atoc.attr_name
361
+ sym = atoc_to_sym(let.atoc)
362
+ key = [sym, attr_name]
363
+ if expr = inhs[key]
364
+ if expr.size == 1 and expr[0].is_a?(N_ATOC) and
365
+ atoc_to_sym(expr[0]) == sym and expr[0].attr_name == attr_name
366
+ # older is self copy, update it.
367
+ inhs.delete(key)
368
+ inhs[key] = replace_atoc expr, inhs
369
+ elsif let.expr.size == 1 and let.expr[0].is_a?(N_ATOC) and
370
+ atoc_to_sym(let.expr[0]) == sym and let.expr[0].attr_name == attr_name
371
+ # newer is self copy, skip.
372
+ elsif not same_semantic? expr, let.expr
373
+ error_exit "LALR-attribute violation."
374
+ end
375
+ else
376
+ inhs[key] = replace_atoc let.expr, inhs
377
+ end
378
+ end
379
+ end
380
+
381
+ # check eclr
382
+ inhs.each do |k, v|
383
+ sym, attr_name = k
384
+ if ec = @ecs[k]
385
+ key = [ec, attr_name]
386
+ if ec_inhs[key]
387
+ unless same_semantic? ec_inhs[key], v
388
+ error_exit "ECLR-attribute violation."
389
+ end
390
+ else
391
+ ec_inhs[key] = v
392
+ end
393
+ else
394
+ ec_inhs[k] = v
395
+ end
396
+ end
397
+
398
+ debug_info "\n----------\n#{state}"
399
+ ec_inhs.each{|k,v| s,a=k;debug_info "#{grammar.symname s}:#{s}.#{a}=>#{v.pretty_inspect}" }
400
+ locals.each{|x,k,v| debug_info "#{x}.#{k}=>#{v.pretty_inspect}"}
401
+ return ec_inhs, locals
402
+ end
403
+
404
+ def same_semantic? sa, sb
405
+ return false unless sa.size == sb.size
406
+ sa.size.times do |x| a, b = sa[x], sb[x]
407
+ return false unless a.class == b.class
408
+ if a.is_a? N_ATOC
409
+ asym = a.sym_name == '$' ? atoc_to_sym(a) : a.sym_name
410
+ bsym = b.sym_name == '$' ? atoc_to_sym(b) : b.sym_name
411
+ asym = @ecs[[asym, a.attr_name]] if @ecs[[asym, a.attr_name]]
412
+ bsym = @ecs[[bsym, b.attr_name]] if @ecs[[bsym, b.attr_name]]
413
+ return false unless asym == bsym && a.attr_name == b.attr_name
414
+ else
415
+ return false unless a == b
416
+ end
417
+ end
418
+ return true
419
+ end
420
+
421
+ def replace_atoc expr, inhs={}
422
+ # warn "REPLACE:#{expr.pretty_inspect}"
423
+ res = []
424
+ expr and expr.each do |node|
425
+ if node.is_a? N_ATOC
426
+ if replace_to = inhs[[atoc_to_sym(node), node.attr_name]]
427
+ res.concat replace_to
428
+ else
429
+ res << node
430
+ end
431
+ elsif node.is_a? N_LET or node.is_a? N_ACTION
432
+ replaced = node.dup
433
+ replaced.expr = replace_atoc(node.expr, inhs)
434
+ res << replaced
435
+ else
436
+ res << node
437
+ end
438
+ end
439
+ # warn "=====>:#{res.pretty_inspect}"
440
+ return res
441
+ end
442
+
443
+ def valid_atoc_name? atoc
444
+ return true if local_atoc?(atoc)
445
+ return true if atoc.sym_name == '$'
446
+ return grammar[atoc.rx].rhs_name_to_sym(atoc.sym_name) ? true : false
447
+ end
448
+
449
+ def valid_atoc? atoc
450
+ return true if local_atoc?(atoc)
451
+ return true if atoc.sym_name =~ /^[%#]/
452
+ rule = grammar[atoc.rx]
453
+ sym = atoc.sym_name == '$' ? rule.lhs : rule.rhs_name_to_sym(atoc.sym_name)
454
+ return true if sym and atoc.sym_name =~ /^[A-Z]/ # term(no check)
455
+ sym and @attributes[sym] and @attributes[sym].include?(atoc.attr_name)
456
+ rescue ; warn "ATOC?:#{atoc.pretty_inspect}"; false
457
+ end
458
+
459
+ def rhs_index atoc
460
+ return nil if local_atoc?(atoc)
461
+ grammar[atoc.rx].rhs_names.index(atoc.sym_name)
462
+ end
463
+
464
+ def atoc_to_sym atoc
465
+ return nil if local_atoc?(atoc)
466
+ return $1.to_i if atoc.sym_name =~ /^%(\d+)$/
467
+ return grammar[atoc.rx].lhs if atoc.sym_name == '$'
468
+ grammar[atoc.rx].rhs_name_to_sym(atoc.sym_name) rescue nil
469
+ end
470
+
471
+ def local_atoc? atoc
472
+ atoc.sym_name == nil
473
+ end
474
+
475
+ def inh_atoc? atoc
476
+ !local_atoc?(atoc) and atoc.attr_name[0] == ?_
477
+ end
478
+
479
+ def syn_atoc? atoc
480
+ !local_atoc?(atoc) and atoc.attr_name[0] != ?_
481
+ end
482
+
483
+ def pending_error *args
484
+ @pending_errors ||= []
485
+ @pending_errors << g_parser.error_message(*args)
486
+ end
487
+
488
+ def error_exit_if_error_pending
489
+ @pending_errors and error_exit(@pending_errors.join("\n"))
490
+ end
491
+
492
+ def debug_info s
493
+ Depager.debug_mode? and File.open(@debug_output_path, 'a'){|f| f.write s}
494
+ end
495
+
496
+ def generate_rie_decorator_code on_reduce, on_state, action_code
497
+ on_reduce_code = on_reduce.map{|i| " #{i||'nil'},\n"}
498
+ on_state_code = on_state.map{|i| " #{i||'nil'},\n"}
499
+
500
+ generate_decorator_code(decorator_name, "#{d_parser.parsing_method}::AdvancedParser", <<-CODE)
501
+ on_reduce = [\n#{on_reduce_code.join}
502
+ ]
503
+ on_state = [\n#{on_state_code.join}
504
+ ]
505
+ Tables = [on_reduce, on_state]
506
+ RieATTR = Struct.new(:inh, :syn, :local)
507
+ def initialize inside
508
+ super inside
509
+ @on_reduce, @on_state = self.class::Tables
510
+ end
511
+ def before_parse
512
+ after_shift
513
+ end
514
+ def after_shift
515
+ msg = @on_state[stack.last] and send(msg)
516
+ end
517
+ def before_reduce
518
+ stack.last == 0 and after_shift
519
+ @_rie_reduce_syn = {}
520
+ mes = @on_reduce[-action_value] and send(mes)
521
+ end
522
+ require 'pp'
523
+ def after_reduce
524
+ _sstack(-1); stack[-2][decorator_index].syn = @_rie_reduce_syn
525
+ after_shift
526
+ end
527
+ def _sstack n
528
+ n = n * 2
529
+ if -n == stack.size + 1
530
+ @_attr_for_state0 ||= RieATTR[{}, {}, {}]
531
+ else
532
+ stack[n][decorator_index] ||= RieATTR[{}, stack[n][1] == :NT ? {} : stack[n][1], {}]
533
+ end
534
+ rescue
535
+ warn "N:\#{n}"
536
+ raise
537
+ end
538
+ \n#{action_code}
539
+ CODE
540
+ end
541
+
542
+ DEPAGER_EXPANDED_CODE
543
+
544
+ end
545
+
546
+ ###
547
+ ### Depager::RieExtension::PostLhs0 - Part of Depager Extension (slave)
548
+ ###
549
+
550
+ module Depager::RieExtension::PostLhs0 #:nodoc:all
551
+ class Parser < Depager::LALR::Basis #:nodoc:all
552
+ include Depager::Utils::ExtensionSlaveMethods
553
+
554
+ ### Reduce Table
555
+ REDUCE_TABLE = [
556
+ [ -1, 1 ],
557
+ [ 0, 3 ],
558
+ [ 1, 1 ],
559
+ [ 1, 3 ],
560
+ [ 2, 1 ],
561
+ [ 2, 3 ],
562
+ ]
563
+ def reduce_table; REDUCE_TABLE; end
564
+
565
+ ### Term to Int
566
+ TERM_TO_INT = {
567
+ nil => 0,
568
+ false => 1,
569
+ "[" => 2,
570
+ "]" => 3,
571
+ "," => 4,
572
+ :ID => 5,
573
+ ":" => 6,
574
+ }
575
+ def term_to_int; TERM_TO_INT; end
576
+
577
+ ### Int to Term
578
+ INT_TO_TERM = [
579
+ nil,
580
+ false,
581
+ "[",
582
+ "]",
583
+ ",",
584
+ :ID,
585
+ ":",
586
+ ]
587
+ def int_to_term; INT_TO_TERM; end
588
+
589
+ ### Action Table
590
+ ACTION_TABLE = [
591
+ [ nil, nil, 2, nil, nil, nil, nil, ],
592
+ [ ACC, nil, nil, nil, nil, nil, nil, ],
593
+ [ nil, nil, nil, nil, nil, 5, nil, ],
594
+ [ nil, nil, nil, 6, 7, nil, nil, ],
595
+ [ nil, nil, nil, nil, nil, nil, nil, ],
596
+ [ nil, nil, nil, nil, nil, nil, 8, ],
597
+ [ nil, nil, nil, nil, nil, nil, nil, ],
598
+ [ nil, nil, nil, nil, nil, 5, nil, ],
599
+ [ nil, nil, nil, nil, nil, 10, nil, ],
600
+ [ nil, nil, nil, nil, nil, nil, nil, ],
601
+ [ nil, nil, nil, nil, nil, nil, nil, ],
602
+ ]
603
+ def action_table; ACTION_TABLE; end
604
+
605
+ ### Default Reduce Table
606
+ DEFRED_TABLE = [
607
+ nil,
608
+ nil,
609
+ nil,
610
+ nil,
611
+ -2,
612
+ -4,
613
+ -1,
614
+ nil,
615
+ nil,
616
+ -3,
617
+ -5,
618
+ ]
619
+ def defred_table; DEFRED_TABLE; end
620
+
621
+ DEFRED_AFTER_SHIFT_TABLE = [
622
+ nil,
623
+ nil,
624
+ nil,
625
+ nil,
626
+ -2,
627
+ nil,
628
+ -1,
629
+ nil,
630
+ nil,
631
+ -3,
632
+ -5,
633
+ ]
634
+ def defred_after_shift_table; DEFRED_AFTER_SHIFT_TABLE; end
635
+
636
+ ### Nonterm to Int
637
+ NONTERM_TO_INT = {
638
+ :start => 0,
639
+ :attr_list => 1,
640
+ :attr => 2,
641
+ }
642
+ def nonterm_to_int; NONTERM_TO_INT; end
643
+
644
+ ### Int to Nonterm
645
+ INT_TO_NONTERM = [
646
+ :start,
647
+ :attr_list,
648
+ :attr,
649
+ ]
650
+ def int_to_nonterm; INT_TO_NONTERM; end
651
+
652
+ ### Goto Table
653
+ GOTO_TABLE = [
654
+ [ 1, nil, nil, ],
655
+ [ nil, nil, nil, ],
656
+ [ nil, 3, 4, ],
657
+ [ nil, nil, nil, ],
658
+ [ nil, nil, nil, ],
659
+ [ nil, nil, nil, ],
660
+ [ nil, nil, nil, ],
661
+ [ nil, nil, 9, ],
662
+ [ nil, nil, nil, ],
663
+ [ nil, nil, nil, ],
664
+ [ nil, nil, nil, ],
665
+ ]
666
+ def goto_table; GOTO_TABLE; end
667
+
668
+ def initialize g_parser, master
669
+ super()
670
+ @g_parser = g_parser
671
+ @d_parser = g_parser.d_parser
672
+ @master = master
673
+ @decorated = Action.new(self)
674
+ end
675
+
676
+
677
+ def do_parse?
678
+ if @line.match(/^\s*\[/)
679
+
680
+ true
681
+ else
682
+ false
683
+ end
684
+ end
685
+
686
+
687
+ def banner
688
+ "[...] / Depager::RieExtension"
689
+ end
690
+
691
+ def lex
692
+ begin
693
+ until @line.empty?
694
+ case @line
695
+ when /\A\s+/
696
+ @line = $'
697
+
698
+
699
+ when /\A[a-zA-Z_]\w*/
700
+ @line = $'
701
+ yield token(:ID, $&)
702
+
703
+ when /\A\]/
704
+ @line = $'
705
+ yield token(']'); yield token(nil)
706
+
707
+ when /\A./
708
+ @line = $'
709
+ yield token($&)
710
+
711
+
712
+ else
713
+ raise RuntimeError, "must not happen #{@line}"
714
+ end
715
+ end
716
+ end while @original_line = @line = file.gets
717
+ yield nil, nil
718
+ end
719
+ module_eval <<'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 525
720
+ def do_default
721
+ master.attributes[g_parser.lhs] = []
722
+ end
723
+
724
+ DEPAGER_EXPANDED_CODE
725
+
726
+ end
727
+ end
728
+
729
+ class Depager::RieExtension::PostLhs0::Action < Depager::LALR::Action #:nodoc:all
730
+ include Depager::Utils::ExtensionSlaveDecoratorMethods
731
+ ON_REDUCE = [
732
+ nil,
733
+ :_act_1,
734
+ :_act_2,
735
+ :_act_3,
736
+ :_act_4,
737
+ :_act_5,
738
+
739
+ ]
740
+ def on_reduce; ON_REDUCE; end
741
+
742
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 536
743
+ def _act_1 val
744
+ _, _attr_list, _, = *val
745
+ master.attributes[g_parser.lhs] = _attr_list
746
+
747
+ end
748
+ DEPAGER_EXPANDED_CODE
749
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 539
750
+ def _act_2 val
751
+ _attr, = *val
752
+ [ _attr ]
753
+
754
+ end
755
+ DEPAGER_EXPANDED_CODE
756
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 541
757
+ def _act_3 val
758
+ _attr_list, _, _attr, = *val
759
+
760
+ if _attr_list.include? _attr
761
+ warning "attribute `#{_attr}' reappeared."
762
+ _attr_list
763
+ else
764
+ _attr_list << _attr
765
+ end
766
+
767
+ end
768
+ DEPAGER_EXPANDED_CODE
769
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 551
770
+ def _act_4 val
771
+ _ID, = *val
772
+ _ID.value
773
+
774
+ end
775
+ DEPAGER_EXPANDED_CODE
776
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 553
777
+ def _act_5 val
778
+ _ID, _, _ec, = *val
779
+
780
+ unless _ID.value[0] == ?_
781
+ error_exit "EC must be inherited attribute.", _ec.lineno
782
+ else
783
+ master.ecs[[g_parser.lhs, _ID.value]] = _ec.value
784
+ end
785
+ _ID.value
786
+
787
+ end
788
+ DEPAGER_EXPANDED_CODE
789
+
790
+
791
+ end
792
+
793
+ ###
794
+ ### Depager::RieExtension::PostRhs1 - Part of Depager Extension (slave)
795
+ ###
796
+
797
+ module Depager::RieExtension::PostRhs1 #:nodoc:all
798
+ class Parser < Depager::LALR::Basis #:nodoc:all
799
+ include Depager::Utils::ExtensionSlaveMethods
800
+
801
+ ### Reduce Table
802
+ REDUCE_TABLE = [
803
+ [ -1, 1 ],
804
+ [ 0, 3 ],
805
+ [ 1, 1 ],
806
+ [ 1, 3 ],
807
+ [ 2, 0 ],
808
+ [ 2, 2 ],
809
+ [ 2, 2 ],
810
+ [ 2, 2 ],
811
+ [ 2, 4 ],
812
+ [ 2, 3 ],
813
+ [ 2, 3 ],
814
+ [ 2, 3 ],
815
+ [ 2, 1 ],
816
+ [ 7, 1 ],
817
+ [ 7, 2 ],
818
+ [ 7, 3 ],
819
+ [ 6, 1 ],
820
+ [ 6, 2 ],
821
+ [ 8, 1 ],
822
+ [ 8, 1 ],
823
+ [ 8, 1 ],
824
+ [ 8, 1 ],
825
+ [ 8, 1 ],
826
+ [ 8, 1 ],
827
+ [ 8, 2 ],
828
+ [ 8, 3 ],
829
+ [ 8, 2 ],
830
+ [ 8, 3 ],
831
+ [ 8, 2 ],
832
+ [ 8, 3 ],
833
+ [ 4, 1 ],
834
+ [ 4, 3 ],
835
+ [ 5, 3 ],
836
+ [ 3, 1 ],
837
+ [ 3, 3 ],
838
+ ]
839
+ def reduce_table; REDUCE_TABLE; end
840
+
841
+ ### Term to Int
842
+ TERM_TO_INT = {
843
+ nil => 0,
844
+ false => 1,
845
+ "{" => 2,
846
+ "}" => 3,
847
+ ";" => 4,
848
+ :THREAD => 5,
849
+ :TRANSFER => 6,
850
+ :EXCEPT => 7,
851
+ "=" => 8,
852
+ :LID => 9,
853
+ :ID => 10,
854
+ :RBTOKEN => 11,
855
+ "." => 12,
856
+ "," => 13,
857
+ "[" => 14,
858
+ "]" => 15,
859
+ "(" => 16,
860
+ ")" => 17,
861
+ }
862
+ def term_to_int; TERM_TO_INT; end
863
+
864
+ ### Int to Term
865
+ INT_TO_TERM = [
866
+ nil,
867
+ false,
868
+ "{",
869
+ "}",
870
+ ";",
871
+ :THREAD,
872
+ :TRANSFER,
873
+ :EXCEPT,
874
+ "=",
875
+ :LID,
876
+ :ID,
877
+ :RBTOKEN,
878
+ ".",
879
+ ",",
880
+ "[",
881
+ "]",
882
+ "(",
883
+ ")",
884
+ ]
885
+ def int_to_term; INT_TO_TERM; end
886
+
887
+ ### Action Table
888
+ ACTION_TABLE = [
889
+ [ nil, nil, 2, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
890
+ [ ACC, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
891
+ [ nil, nil, 17, nil, nil, 5, 6, 7, nil, 9, 10, 13, 14, 15, 16, nil, 18, nil, ],
892
+ [ nil, nil, nil, 19, 20, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
893
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
894
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 22, nil, nil, nil, nil, nil, nil, nil, ],
895
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 22, nil, nil, nil, nil, nil, nil, nil, ],
896
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 26, nil, nil, nil, nil, nil, nil, nil, ],
897
+ [ nil, nil, nil, nil, nil, nil, nil, nil, 27, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
898
+ [ nil, nil, nil, nil, nil, nil, nil, nil, 28, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
899
+ [ nil, nil, nil, nil, nil, nil, nil, nil, 29, nil, nil, nil, 30, nil, nil, nil, nil, nil, ],
900
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
901
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
902
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
903
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
904
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
905
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, 35, 18, nil, ],
906
+ [ nil, nil, 17, 38, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
907
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, 40, ],
908
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
909
+ [ nil, nil, 17, nil, nil, 5, 6, 7, nil, 9, 10, 13, 14, 15, 16, nil, 18, nil, ],
910
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 43, nil, nil, nil, nil, ],
911
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
912
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 43, nil, nil, nil, nil, ],
913
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 44, nil, nil, nil, nil, ],
914
+ [ nil, nil, nil, nil, nil, nil, nil, nil, 45, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
915
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 30, nil, nil, nil, nil, nil, ],
916
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
917
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
918
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
919
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 49, nil, nil, nil, nil, nil, nil, nil, ],
920
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
921
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
922
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 30, nil, nil, nil, nil, nil, ],
923
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
924
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
925
+ [ nil, nil, nil, nil, 50, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 51, nil, nil, ],
926
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
927
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
928
+ [ nil, nil, nil, 52, 50, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
929
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
930
+ [ nil, nil, nil, nil, 50, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 53, ],
931
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
932
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 54, nil, nil, nil, nil, nil, nil, nil, ],
933
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, 26, nil, nil, nil, nil, nil, nil, nil, ],
934
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
935
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
936
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
937
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
938
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
939
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
940
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
941
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
942
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
943
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
944
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
945
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
946
+ [ nil, nil, 17, nil, nil, nil, nil, nil, nil, 34, 33, 13, 14, 15, 16, nil, 18, nil, ],
947
+ ]
948
+ def action_table; ACTION_TABLE; end
949
+
950
+ ### Default Reduce Table
951
+ DEFRED_TABLE = [
952
+ nil,
953
+ nil,
954
+ -4,
955
+ nil,
956
+ -2,
957
+ nil,
958
+ nil,
959
+ nil,
960
+ -18,
961
+ -20,
962
+ -19,
963
+ -12,
964
+ -16,
965
+ -21,
966
+ -22,
967
+ -23,
968
+ nil,
969
+ nil,
970
+ nil,
971
+ -1,
972
+ -4,
973
+ -5,
974
+ -33,
975
+ -6,
976
+ -7,
977
+ -30,
978
+ nil,
979
+ nil,
980
+ nil,
981
+ nil,
982
+ nil,
983
+ -17,
984
+ -18,
985
+ -19,
986
+ -20,
987
+ -24,
988
+ nil,
989
+ -13,
990
+ -26,
991
+ nil,
992
+ -28,
993
+ nil,
994
+ -3,
995
+ nil,
996
+ nil,
997
+ nil,
998
+ -9,
999
+ -10,
1000
+ -11,
1001
+ -32,
1002
+ -14,
1003
+ -25,
1004
+ -27,
1005
+ -29,
1006
+ -34,
1007
+ -31,
1008
+ -8,
1009
+ -15,
1010
+ ]
1011
+ def defred_table; DEFRED_TABLE; end
1012
+
1013
+ DEFRED_AFTER_SHIFT_TABLE = [
1014
+ nil,
1015
+ nil,
1016
+ nil,
1017
+ nil,
1018
+ -2,
1019
+ nil,
1020
+ nil,
1021
+ nil,
1022
+ nil,
1023
+ nil,
1024
+ nil,
1025
+ nil,
1026
+ -16,
1027
+ -21,
1028
+ -22,
1029
+ -23,
1030
+ nil,
1031
+ nil,
1032
+ nil,
1033
+ -1,
1034
+ nil,
1035
+ nil,
1036
+ -33,
1037
+ nil,
1038
+ nil,
1039
+ nil,
1040
+ nil,
1041
+ nil,
1042
+ nil,
1043
+ nil,
1044
+ nil,
1045
+ -17,
1046
+ -18,
1047
+ nil,
1048
+ -20,
1049
+ -24,
1050
+ nil,
1051
+ nil,
1052
+ -26,
1053
+ nil,
1054
+ -28,
1055
+ nil,
1056
+ -3,
1057
+ nil,
1058
+ nil,
1059
+ nil,
1060
+ nil,
1061
+ nil,
1062
+ nil,
1063
+ -32,
1064
+ nil,
1065
+ -25,
1066
+ -27,
1067
+ -29,
1068
+ -34,
1069
+ -31,
1070
+ nil,
1071
+ nil,
1072
+ ]
1073
+ def defred_after_shift_table; DEFRED_AFTER_SHIFT_TABLE; end
1074
+
1075
+ ### Nonterm to Int
1076
+ NONTERM_TO_INT = {
1077
+ :start => 0,
1078
+ :stmt_list => 1,
1079
+ :stmt => 2,
1080
+ :id_list => 3,
1081
+ :lhs_list => 4,
1082
+ :lhs => 5,
1083
+ :rbexpr => 6,
1084
+ :rbexpr_list => 7,
1085
+ :rbelem => 8,
1086
+ }
1087
+ def nonterm_to_int; NONTERM_TO_INT; end
1088
+
1089
+ ### Int to Nonterm
1090
+ INT_TO_NONTERM = [
1091
+ :start,
1092
+ :stmt_list,
1093
+ :stmt,
1094
+ :id_list,
1095
+ :lhs_list,
1096
+ :lhs,
1097
+ :rbexpr,
1098
+ :rbexpr_list,
1099
+ :rbelem,
1100
+ ]
1101
+ def int_to_nonterm; INT_TO_NONTERM; end
1102
+
1103
+ ### Goto Table
1104
+ GOTO_TABLE = [
1105
+ [ 1, nil, nil, nil, nil, nil, nil, nil, nil, ],
1106
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1107
+ [ nil, 3, 4, nil, nil, 8, 11, nil, 12, ],
1108
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1109
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1110
+ [ nil, nil, nil, 21, nil, nil, nil, nil, nil, ],
1111
+ [ nil, nil, nil, 23, nil, nil, nil, nil, nil, ],
1112
+ [ nil, nil, nil, nil, 24, 25, nil, nil, nil, ],
1113
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1114
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1115
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1116
+ [ nil, nil, nil, nil, nil, 32, nil, nil, 31, ],
1117
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1118
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1119
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1120
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1121
+ [ nil, nil, nil, nil, nil, 32, 37, 36, 12, ],
1122
+ [ nil, nil, nil, nil, nil, 32, 37, 39, 12, ],
1123
+ [ nil, nil, nil, nil, nil, 32, 37, 41, 12, ],
1124
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1125
+ [ nil, nil, 42, nil, nil, 8, 11, nil, 12, ],
1126
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1127
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1128
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1129
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1130
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1131
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1132
+ [ nil, nil, nil, nil, nil, 32, 46, nil, 12, ],
1133
+ [ nil, nil, nil, nil, nil, 32, 47, nil, 12, ],
1134
+ [ nil, nil, nil, nil, nil, 32, 48, nil, 12, ],
1135
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1136
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1137
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1138
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1139
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1140
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1141
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1142
+ [ nil, nil, nil, nil, nil, 32, nil, nil, 31, ],
1143
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1144
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1145
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1146
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1147
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1148
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1149
+ [ nil, nil, nil, nil, nil, 55, nil, nil, nil, ],
1150
+ [ nil, nil, nil, nil, nil, 32, 56, nil, 12, ],
1151
+ [ nil, nil, nil, nil, nil, 32, nil, nil, 31, ],
1152
+ [ nil, nil, nil, nil, nil, 32, nil, nil, 31, ],
1153
+ [ nil, nil, nil, nil, nil, 32, nil, nil, 31, ],
1154
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1155
+ [ nil, nil, nil, nil, nil, 32, 57, nil, 12, ],
1156
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1157
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1158
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1159
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1160
+ [ nil, nil, nil, nil, nil, nil, nil, nil, nil, ],
1161
+ [ nil, nil, nil, nil, nil, 32, nil, nil, 31, ],
1162
+ [ nil, nil, nil, nil, nil, 32, nil, nil, 31, ],
1163
+ ]
1164
+ def goto_table; GOTO_TABLE; end
1165
+
1166
+ def initialize g_parser, master
1167
+ super()
1168
+ @g_parser = g_parser
1169
+ @d_parser = g_parser.d_parser
1170
+ @master = master
1171
+ @decorated = Action.new(self)
1172
+ end
1173
+
1174
+
1175
+ def do_parse?
1176
+ if @line.match(/^\s*\{/)
1177
+
1178
+ true
1179
+ else
1180
+ false
1181
+ end
1182
+ end
1183
+
1184
+
1185
+ def banner
1186
+ "{...} / Depager::RieExtension"
1187
+ end
1188
+
1189
+ def lex
1190
+ begin
1191
+ until @line.empty?
1192
+ case @line
1193
+ when /\A#.*/
1194
+ @line = $'
1195
+
1196
+
1197
+ when /\A[ \t]+/
1198
+ @line = $'
1199
+
1200
+
1201
+ when /\A\r?\n/
1202
+ @line = $'
1203
+ yield token(';')
1204
+
1205
+ when /\A\s*\(/
1206
+ @line = $'
1207
+ yield token('(', $&) ; skip_space
1208
+
1209
+ when /\A\s*\[/
1210
+ @line = $'
1211
+ yield token('[', $&) ; skip_space
1212
+
1213
+ when /\A\s*\{/
1214
+ @line = $'
1215
+ yield token('{', $&) ; skip_space ; @nest +=1
1216
+
1217
+ when /\A\}/
1218
+ @line = $'
1219
+ yield token('}'); (@nest-=1) == 0 and yield token(nil)
1220
+
1221
+ when /\A\./
1222
+ @line = $'
1223
+ yield token('.') ; @_mode = :AFTER_DOT
1224
+
1225
+ when /\A,/
1226
+ @line = $'
1227
+ yield token(','); @line.match(/[\s\n]*/) and @line = $'
1228
+
1229
+ when /\A%transfer/
1230
+ @line = $'
1231
+ yield token(:TRANSFER)
1232
+
1233
+ when /\A%thread/
1234
+ @line = $'
1235
+ yield token(:THREAD)
1236
+
1237
+ when /\A%except/
1238
+ @line = $'
1239
+ yield token(:EXCEPT)
1240
+
1241
+ when /\A\$\./
1242
+ @line = $'
1243
+ yield token(:ID, '$'); yield token('.') ; @_mode = :AFTER_DOT
1244
+
1245
+ when /\A'([^'\\]+|\\.)*'/, /\A"([^"\\]+|\\.)*"/, /\A\/([^\/\\]+|\\.)*\//, /\A(@|$|:)[a-zA-Z_]\w*/, /\A[a-zA-Z_]\w*[!?]/, /\A\d+/
1246
+ @line = $'
1247
+ yield token(:RBTOKEN, $&)
1248
+
1249
+ when /\A(<=|>=|=>|==|===|!=|and|or)/, /\A([+!~*\-\/%^<>&|?:]+|\.\.\.?)/
1250
+ @line = $'
1251
+ yield token(:RBTOKEN, $&) ; skip_space
1252
+
1253
+ when /\A=/
1254
+ @line = $'
1255
+ yield token('=') ; skip_space
1256
+
1257
+ when /\A[a-zA-Z_]\w*/
1258
+ @line = $'
1259
+
1260
+ if @_mode != :AFTER_DOT and @locals[$&]
1261
+ yield token(:LID, $&)
1262
+ else
1263
+ @_mode = nil
1264
+ yield token(:ID, $&)
1265
+ end
1266
+
1267
+ when /\A./
1268
+ @line = $'
1269
+ yield token($&)
1270
+
1271
+
1272
+ else
1273
+ raise RuntimeError, "must not happen #{@line}"
1274
+ end
1275
+ end
1276
+ end while @original_line = @line = file.gets
1277
+ yield nil, nil
1278
+ end
1279
+ module_eval <<'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 569
1280
+ attr_accessor :locals
1281
+ def before_parse
1282
+ @nest = 0
1283
+ @locals = {}
1284
+ end
1285
+ def do_default
1286
+ master.semantics[g_parser.rules.size-1] = []
1287
+ end
1288
+ def skip_space
1289
+ begin
1290
+ @line.match(/^[\s\n]+(#[.\n]*)?/) and @line = $'
1291
+ break unless @line.empty?
1292
+ end while @original_line = @line = getline
1293
+ end
1294
+ def getline
1295
+ begin ; line = @file.gets
1296
+ end while line and line =~ /^\s*(#.*)?$/
1297
+ line
1298
+ end
1299
+
1300
+ DEPAGER_EXPANDED_CODE
1301
+
1302
+ end
1303
+ end
1304
+
1305
+ class Depager::RieExtension::PostRhs1::Action < Depager::LALR::Action #:nodoc:all
1306
+ include Depager::Utils::ExtensionSlaveDecoratorMethods
1307
+ ON_REDUCE = [
1308
+ nil,
1309
+ :_act_1,
1310
+ :_act_2,
1311
+ :_act_3,
1312
+ :_act_4,
1313
+ :_act_5,
1314
+ :_act_6,
1315
+ :_act_7,
1316
+ :_act_8,
1317
+ :_act_9,
1318
+ :_act_10,
1319
+ :_act_11,
1320
+ :_act_12,
1321
+ :_act_13,
1322
+ :_act_14,
1323
+ :_act_15,
1324
+ :_act_16,
1325
+ :_act_17,
1326
+ :_act_18,
1327
+ :_act_19,
1328
+ :_act_20,
1329
+ :_act_21,
1330
+ :_act_22,
1331
+ :_act_23,
1332
+ :_act_24,
1333
+ :_act_25,
1334
+ :_act_26,
1335
+ :_act_27,
1336
+ :_act_28,
1337
+ :_act_29,
1338
+ :_act_30,
1339
+ :_act_31,
1340
+ :_act_32,
1341
+ :_act_33,
1342
+ :_act_34,
1343
+
1344
+ ]
1345
+ def on_reduce; ON_REDUCE; end
1346
+
1347
+ include Depager::RieExtension::Nodes
1348
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 633
1349
+ def _act_1 val
1350
+ _, _stmt_list, _, = *val
1351
+
1352
+ basis.locals.clear
1353
+ master.semantics[g_parser.rules.size-1] = _stmt_list.compact
1354
+
1355
+ end
1356
+ DEPAGER_EXPANDED_CODE
1357
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 642
1358
+ def _act_2 val
1359
+ _stmt, = *val
1360
+
1361
+ if _stmt.is_a? N_EXCEPT
1362
+ error_exit "invalid %except.", _stmt.lineno
1363
+ end
1364
+ [ _stmt ]
1365
+
1366
+ end
1367
+ DEPAGER_EXPANDED_CODE
1368
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 649
1369
+ def _act_3 val
1370
+ _stmt_list, _, _stmt, = *val
1371
+
1372
+ if _stmt.is_a? N_EXCEPT
1373
+ unless [N_THREAD, N_TRANSFER].include?(_stmt_list.last.class)
1374
+ error_exit "invalid %except.", _stmt.lineno
1375
+ end
1376
+ let_or_ids = _stmt.let_or_ids
1377
+ if let_or_ids.is_a? N_LET
1378
+ _stmt_list.last.excepts << let_or_ids.atoc
1379
+ _stmt_list.insert(_stmt_list.size-1, let_or_ids)
1380
+ else
1381
+ _stmt_list.last.excepts.concat(let_or_ids)
1382
+ _stmt_list
1383
+ end
1384
+ else
1385
+ _stmt ? (_stmt_list << _stmt) : _stmt_list
1386
+ end
1387
+
1388
+ end
1389
+ DEPAGER_EXPANDED_CODE
1390
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 668
1391
+ def _act_4 val
1392
+ # empty rule
1393
+ nil
1394
+
1395
+ end
1396
+ DEPAGER_EXPANDED_CODE
1397
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 669
1398
+ def _act_5 val
1399
+ _THREAD, _id_list, = *val
1400
+ N_THREAD[val[0].lineno, _id_list, []]
1401
+
1402
+ end
1403
+ DEPAGER_EXPANDED_CODE
1404
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 670
1405
+ def _act_6 val
1406
+ _TRANSFER, _id_list, = *val
1407
+ N_TRANSFER[val[0].lineno, _id_list, []]
1408
+
1409
+ end
1410
+ DEPAGER_EXPANDED_CODE
1411
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 671
1412
+ def _act_7 val
1413
+ _EXCEPT, _lhs_list, = *val
1414
+ N_EXCEPT[val[0].lineno, lhs_list]
1415
+
1416
+ end
1417
+ DEPAGER_EXPANDED_CODE
1418
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 672
1419
+ def _act_8 val
1420
+ _EXCEPT, _lhs, _, _rbexpr, = *val
1421
+ N_EXCEPT[val[0].lineno, N_LET[_lhs.lineno, _lhs, _rbexpr]]
1422
+
1423
+ end
1424
+ DEPAGER_EXPANDED_CODE
1425
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 673
1426
+ def _act_9 val
1427
+ _lhs, _, _rbexpr, = *val
1428
+ N_LET[_lhs.lineno, _lhs, _rbexpr]
1429
+
1430
+ end
1431
+ DEPAGER_EXPANDED_CODE
1432
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 675
1433
+ def _act_10 val
1434
+ _LID, _, _rbexpr, = *val
1435
+
1436
+ N_LET[val[0].lineno, N_ATOC[val[0].lineno, nil, _LID.value, g_parser.rules.size-1], _rbexpr]
1437
+
1438
+ end
1439
+ DEPAGER_EXPANDED_CODE
1440
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 679
1441
+ def _act_11 val
1442
+ _ID, _, _rbexpr, = *val
1443
+
1444
+ basis.locals[_ID.value] = true
1445
+ N_LET[val[0].lineno, N_ATOC[val[0].lineno, nil, _ID.value, g_parser.rules.size-1], _rbexpr]
1446
+
1447
+ end
1448
+ DEPAGER_EXPANDED_CODE
1449
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 683
1450
+ def _act_12 val
1451
+ _rbexpr, = *val
1452
+ N_ACTION[basis.file.lineno, _rbexpr ]
1453
+
1454
+ end
1455
+ DEPAGER_EXPANDED_CODE
1456
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 687
1457
+ def _act_13 val
1458
+ _rbexpr, = *val
1459
+ _rbexpr
1460
+
1461
+ end
1462
+ DEPAGER_EXPANDED_CODE
1463
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 688
1464
+ def _act_14 val
1465
+ _rbexpr_list, _, = *val
1466
+ _rbexpr_list
1467
+
1468
+ end
1469
+ DEPAGER_EXPANDED_CODE
1470
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 689
1471
+ def _act_15 val
1472
+ _rbexpr_list, _, _rbexpr, = *val
1473
+ (_rbexpr_list << ';').concat _rbexpr
1474
+
1475
+ end
1476
+ DEPAGER_EXPANDED_CODE
1477
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 692
1478
+ def _act_16 val
1479
+ _rbelem, = *val
1480
+ _rbelem
1481
+
1482
+ end
1483
+ DEPAGER_EXPANDED_CODE
1484
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 693
1485
+ def _act_17 val
1486
+ _rbexpr, _rbelem, = *val
1487
+ _rbexpr.concat _rbelem
1488
+
1489
+ end
1490
+ DEPAGER_EXPANDED_CODE
1491
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 696
1492
+ def _act_18 val
1493
+ _lhs, = *val
1494
+ [_lhs]
1495
+
1496
+ end
1497
+ DEPAGER_EXPANDED_CODE
1498
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 697
1499
+ def _act_19 val
1500
+ _ID, = *val
1501
+ [_ID.value]
1502
+
1503
+ end
1504
+ DEPAGER_EXPANDED_CODE
1505
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 698
1506
+ def _act_20 val
1507
+ _LID, = *val
1508
+ [ N_ATOC[_LID.lineno, nil, _LID.value, g_parser.rules.size-1] ]
1509
+
1510
+ end
1511
+ DEPAGER_EXPANDED_CODE
1512
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 699
1513
+ def _act_21 val
1514
+ _RBTOKEN, = *val
1515
+ [_RBTOKEN.value]
1516
+
1517
+ end
1518
+ DEPAGER_EXPANDED_CODE
1519
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 700
1520
+ def _act_22 val
1521
+ _, = *val
1522
+ ['.']
1523
+
1524
+ end
1525
+ DEPAGER_EXPANDED_CODE
1526
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 701
1527
+ def _act_23 val
1528
+ _, = *val
1529
+ [',']
1530
+
1531
+ end
1532
+ DEPAGER_EXPANDED_CODE
1533
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 702
1534
+ def _act_24 val
1535
+ _, _, = *val
1536
+ [ val[0].value, ']' ]
1537
+
1538
+ end
1539
+ DEPAGER_EXPANDED_CODE
1540
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 703
1541
+ def _act_25 val
1542
+ _, _rbexpr_list, _, = *val
1543
+ [ val[0].value ].concat(_rbexpr_list) << ']'
1544
+
1545
+ end
1546
+ DEPAGER_EXPANDED_CODE
1547
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 704
1548
+ def _act_26 val
1549
+ _, _, = *val
1550
+ [ val[0].value, '}' ]
1551
+
1552
+ end
1553
+ DEPAGER_EXPANDED_CODE
1554
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 705
1555
+ def _act_27 val
1556
+ _, _rbexpr_list, _, = *val
1557
+ [ val[0].value ].concat(_rbexpr_list) << '}'
1558
+
1559
+ end
1560
+ DEPAGER_EXPANDED_CODE
1561
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 706
1562
+ def _act_28 val
1563
+ _, _, = *val
1564
+ [ val[0].value, ')' ]
1565
+
1566
+ end
1567
+ DEPAGER_EXPANDED_CODE
1568
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 707
1569
+ def _act_29 val
1570
+ _, _rbexpr_list, _, = *val
1571
+ [ val[0].value ].concat(_rbexpr_list) << ')'
1572
+
1573
+ end
1574
+ DEPAGER_EXPANDED_CODE
1575
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 712
1576
+ def _act_30 val
1577
+ _lhs, = *val
1578
+ [ _lhs ]
1579
+
1580
+ end
1581
+ DEPAGER_EXPANDED_CODE
1582
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 713
1583
+ def _act_31 val
1584
+ _lhs_list, _, _lhs, = *val
1585
+ lhs_list << lhs
1586
+
1587
+ end
1588
+ DEPAGER_EXPANDED_CODE
1589
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 716
1590
+ def _act_32 val
1591
+ _ID, _, _attr, = *val
1592
+ N_ATOC[_ID.lineno, _ID.value, _attr.value, g_parser.rules.size-1]
1593
+
1594
+ end
1595
+ DEPAGER_EXPANDED_CODE
1596
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 719
1597
+ def _act_33 val
1598
+ _ID, = *val
1599
+ [ _ID.value ]
1600
+
1601
+ end
1602
+ DEPAGER_EXPANDED_CODE
1603
+ module_eval <<-'DEPAGER_EXPANDED_CODE', 'lib/depager/plugins/rie.dr', 720
1604
+ def _act_34 val
1605
+ _id_list, _, _ID, = *val
1606
+ _id_list << _ID.value
1607
+
1608
+ end
1609
+ DEPAGER_EXPANDED_CODE
1610
+
1611
+
1612
+ end
1613
+
1614
+