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.
- checksums.yaml +7 -0
 - data/.rubocop.yml +44 -0
 - data/.simplecov +5 -0
 - data/Gemfile +12 -0
 - data/LICENSE.gpl +339 -0
 - data/Manifest.txt +73 -0
 - data/README.en +7 -21
 - data/README.ja +19 -99
 - data/Rakefile +31 -0
 - data/bin/depager +7 -45
 - data/examples/action_pl0d/pl0d.action.dr +421 -0
 - data/examples/action_pl0d/test.pl0ds +48 -0
 - data/examples/c89/c89.dr +493 -496
 - data/examples/c89/test.c89 +10 -10
 - data/examples/extension/astdf.rb +9 -0
 - data/examples/extension/atree.dr +55 -0
 - data/examples/{sample_calc → extension}/calc.atree.dr +42 -43
 - data/examples/{sample_calc/calc.action.dr → extension/calc.simple_action.dr} +33 -33
 - data/examples/extension/paction.dr +16 -15
 - data/examples/extension/pactiontest.dr +14 -14
 - data/examples/extension/simple_action.rb +46 -0
 - data/examples/pl0d/pl0ds.dr +337 -334
 - data/examples/pl0d/test.pl0ds +33 -33
 - data/examples/rie_calc/calc.rie.dr +57 -0
 - data/examples/rie_calc/test.calc +4 -0
 - data/examples/rie_dcuse/dcuse.rie.dr +71 -0
 - data/examples/rie_dcuse/test.dcuse +1 -0
 - data/examples/rie_pl0/orig_ex/exerrdg.pl0 +44 -0
 - data/examples/rie_pl0/orig_ex/exerrm.pl0 +19 -0
 - data/examples/rie_pl0/orig_ex/exerrmre.pl0 +20 -0
 - data/examples/rie_pl0/orig_ex/exerrtok.pl0 +18 -0
 - data/examples/rie_pl0/orig_ex/exmdg.pl0 +40 -0
 - data/examples/rie_pl0/orig_ex/exmdgwwl.pl0 +43 -0
 - data/examples/rie_pl0/orig_ex/exmrw.pl0 +22 -0
 - data/examples/rie_pl0/orig_ex/exmwwl.pl0 +18 -0
 - data/examples/rie_pl0/orig_ex/exnorw.pl0 +17 -0
 - data/examples/rie_pl0/pl0.rie.dr +450 -0
 - data/examples/rie_pl0/test.pl0 +10 -0
 - data/examples/slex_test/divreg.slex.dr +29 -29
 - data/examples/slex_test/ljoin.slex.dr +36 -36
 - data/examples/slex_test/test.divreg +1 -1
 - data/examples/slex_test/test.ljoin +3 -3
 - data/examples/{sample_calc/calc.nvaction.dr → tiny_calc/calc.action.dr} +33 -33
 - data/examples/{sample_calc → tiny_calc}/calc.ast.action.dr +76 -66
 - data/examples/{sample_calc → tiny_calc}/calc.ast.dr +67 -55
 - data/examples/tiny_calc/calc.cst.dr +50 -0
 - data/examples/{sample_calc → tiny_calc}/calc.dr +43 -43
 - data/examples/{sample_calc → tiny_calc}/calc.lex.dr +29 -29
 - data/examples/{sample_calc/calc_prec.nvaction.dr → tiny_calc/calc_prec.action.dr} +31 -31
 - data/lib/depager/cli.rb +44 -0
 - data/lib/depager/grammar.rb +253 -291
 - data/lib/depager/lr.rb +589 -579
 - data/lib/depager/parser.rb +269 -277
 - data/lib/depager/plugins/_rie_debug.rb +63 -0
 - data/lib/depager/plugins/action.rb +47 -0
 - data/lib/depager/plugins/ast.dr +367 -0
 - data/lib/depager/plugins/ast.rb +1329 -0
 - data/lib/depager/{ruby/plugins → plugins}/cst.dr +174 -180
 - data/lib/depager/plugins/cst.rb +591 -0
 - data/lib/depager/{ruby/plugins → plugins}/lex.dr +85 -89
 - data/lib/depager/plugins/lex.rb +313 -0
 - data/lib/depager/plugins/rie.dr +725 -0
 - data/lib/depager/plugins/rie.rb +1614 -0
 - data/lib/depager/{ruby/plugins → plugins}/slex.dr +201 -200
 - data/lib/depager/plugins/slex.rb +769 -0
 - data/lib/depager/plugins/srp.rb +46 -0
 - data/lib/depager/ruby/templates/extension_lalr_master.erb +40 -51
 - data/lib/depager/ruby/templates/extension_lalr_slave.erb +113 -107
 - data/lib/depager/ruby/templates/single_lalr_parser.erb +124 -117
 - data/lib/depager/utils.rb +158 -318
 - data/lib/depager/version.rb +3 -3
 - data/lib/depager.rb +572 -670
 - metadata +77 -80
 - data/ChangeLog +0 -16
 - data/data/depager/pre-setup.rb +0 -3
 - data/examples/c89/c89.tab.rb +0 -7127
 - data/examples/pl0d/pl0ds.tab.rb +0 -2698
 - data/examples/sample_calc/calc.action.tab.rb +0 -457
 - data/examples/sample_calc/calc.ast.action.tab.rb +0 -749
 - data/examples/sample_calc/calc.ast.tab.rb +0 -665
 - data/examples/sample_calc/calc.astdf.dr +0 -54
 - data/examples/sample_calc/calc.astdf.tab.rb +0 -672
 - data/examples/sample_calc/calc.atree.tab.rb +0 -451
 - data/examples/sample_calc/calc.cst.dr +0 -45
 - data/examples/sample_calc/calc.cst.tab.rb +0 -644
 - data/examples/sample_calc/calc.lex.tab.rb +0 -374
 - data/examples/sample_calc/calc.nvaction.tab.rb +0 -465
 - data/examples/sample_calc/calc.tab.rb +0 -365
 - data/examples/sample_calc/calc_prec.nvaction.tab.rb +0 -431
 - data/examples/slex_test/divreg.slex.tab.rb +0 -303
 - data/examples/slex_test/ljoin.slex.tab.rb +0 -370
 - data/lib/depager/ruby/plugins/_ast_tmpl.rb +0 -73
 - data/lib/depager/ruby/plugins/action.rb +0 -43
 - data/lib/depager/ruby/plugins/ast.dr +0 -269
 - data/lib/depager/ruby/plugins/ast.rb +0 -1308
 - data/lib/depager/ruby/plugins/astdf.rb +0 -6
 - data/lib/depager/ruby/plugins/atree.dr +0 -55
 - data/lib/depager/ruby/plugins/atree.rb +0 -347
 - data/lib/depager/ruby/plugins/cst.rb +0 -626
 - data/lib/depager/ruby/plugins/lex.rb +0 -336
 - data/lib/depager/ruby/plugins/nvaction.rb +0 -19
 - data/lib/depager/ruby/plugins/slex.rb +0 -817
 - data/lib/depager/ruby/plugins/srp.rb +0 -51
 - data/lib/depager/ruby/templates/simple.erb +0 -23
 - data/setup.rb +0 -1585
 - /data/examples/{sample_calc → tiny_calc}/test.calc +0 -0
 
| 
         @@ -0,0 +1,46 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            class Depager::LALR::ShiftReducePrinter < Depager::LALR::AdvancedParser
         
     | 
| 
      
 2 
     | 
    
         
            +
              def dumpstack(stack)
         
     | 
| 
      
 3 
     | 
    
         
            +
                stack.map.with_index do |v, x|
         
     | 
| 
      
 4 
     | 
    
         
            +
                  if x.even?
         
     | 
| 
      
 5 
     | 
    
         
            +
                    "(#{v})"
         
     | 
| 
      
 6 
     | 
    
         
            +
                  elsif v[1] == :NT
         
     | 
| 
      
 7 
     | 
    
         
            +
                    "#{int_to_nonterm[v[0]]}:#{v[1..].inspect}"
         
     | 
| 
      
 8 
     | 
    
         
            +
                  elsif int_to_term[v[0]].instance_of?(String)
         
     | 
| 
      
 9 
     | 
    
         
            +
                    "'#{int_to_term[v[0]]}':#{v[1..].inspect}"
         
     | 
| 
      
 10 
     | 
    
         
            +
                  else
         
     | 
| 
      
 11 
     | 
    
         
            +
                    "#{int_to_term[v[0]]}:#{v[1..].inspect}"
         
     | 
| 
      
 12 
     | 
    
         
            +
                  end
         
     | 
| 
      
 13 
     | 
    
         
            +
                end.join(" ")
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              def after_shift
         
     | 
| 
      
 17 
     | 
    
         
            +
                st0 = stack[stack.size - 3]
         
     | 
| 
      
 18 
     | 
    
         
            +
                st = stack.last
         
     | 
| 
      
 19 
     | 
    
         
            +
                sh = int_to_term[stack[stack.size - 2][0]]
         
     | 
| 
      
 20 
     | 
    
         
            +
                la = int_to_term[lookahead[0]]
         
     | 
| 
      
 21 
     | 
    
         
            +
                warn "LA:<#{la}> shift:<#{sh}> state:#{st0}->#{st}"
         
     | 
| 
      
 22 
     | 
    
         
            +
                warn "LINE:<#{basis.line}>"
         
     | 
| 
      
 23 
     | 
    
         
            +
                warn dumpstack(stack), "\n"
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              def after_reduce
         
     | 
| 
      
 27 
     | 
    
         
            +
                st = stack.last
         
     | 
| 
      
 28 
     | 
    
         
            +
                re = int_to_nonterm[stack[stack.size - 2][0]]
         
     | 
| 
      
 29 
     | 
    
         
            +
                la = int_to_term[lookahead[0]]
         
     | 
| 
      
 30 
     | 
    
         
            +
                warn "LA:<#{la}> reduce:<#{re}> state: ->#{st}"
         
     | 
| 
      
 31 
     | 
    
         
            +
                warn "LINE:<#{basis.line}>"
         
     | 
| 
      
 32 
     | 
    
         
            +
                warn dumpstack(stack), "\n"
         
     | 
| 
      
 33 
     | 
    
         
            +
              end
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
              def after_accept
         
     | 
| 
      
 36 
     | 
    
         
            +
                warn "acc."
         
     | 
| 
      
 37 
     | 
    
         
            +
              end
         
     | 
| 
      
 38 
     | 
    
         
            +
             
     | 
| 
      
 39 
     | 
    
         
            +
              def after_error
         
     | 
| 
      
 40 
     | 
    
         
            +
                st = stack.last
         
     | 
| 
      
 41 
     | 
    
         
            +
                la = int_to_term[lookahead[0]]
         
     | 
| 
      
 42 
     | 
    
         
            +
                warn "LA:<#{la}> last_state:#{st}"
         
     | 
| 
      
 43 
     | 
    
         
            +
                warn "LINE:<#{basis.line}>"
         
     | 
| 
      
 44 
     | 
    
         
            +
                warn dumpstack(stack), "\n"
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -1,51 +1,40 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
               
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
               
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
                @ 
     | 
| 
       30 
     | 
    
         
            -
                @ 
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                 
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
               
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                p.hooks[:<%=i%>].push [@hook[<%=h[m]%>], :do_parse]
         
     | 
| 
       42 
     | 
    
         
            -
                <% x+=1; end %>
         
     | 
| 
       43 
     | 
    
         
            -
                regext p
         
     | 
| 
       44 
     | 
    
         
            -
              end
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
              ### Inner Code
         
     | 
| 
       47 
     | 
    
         
            -
            <%= optinner %>
         
     | 
| 
       48 
     | 
    
         
            -
            end
         
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
            ### Outer Code
         
     | 
| 
       51 
     | 
    
         
            -
            <%= optouter %>
         
     | 
| 
      
 1 
     | 
    
         
            +
            ###
         
     | 
| 
      
 2 
     | 
    
         
            +
            ### <%= d_parser.target_namespace %> - Depager Extension (master)
         
     | 
| 
      
 3 
     | 
    
         
            +
            ###
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'depager/parser.rb'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            <%- @requirements.each do |i| -%>
         
     | 
| 
      
 7 
     | 
    
         
            +
            require <%= i %>
         
     | 
| 
      
 8 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            <%- r = ''; d_parser.target_namespace.split('::')[0..-2].each do |i| -%>
         
     | 
| 
      
 11 
     | 
    
         
            +
            module <%= "#{r}#{i}" %> ; end
         
     | 
| 
      
 12 
     | 
    
         
            +
              <%- r << "#{i}::"-%>
         
     | 
| 
      
 13 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
            class <%= d_parser.target_namespace %> < Depager::Extension
         
     | 
| 
      
 16 
     | 
    
         
            +
              <%- @mixins.uniq.each do |i| -%>
         
     | 
| 
      
 17 
     | 
    
         
            +
              include <%= i %>
         
     | 
| 
      
 18 
     | 
    
         
            +
              <%- end -%>
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
              def initialize
         
     | 
| 
      
 21 
     | 
    
         
            +
                super
         
     | 
| 
      
 22 
     | 
    
         
            +
                @master = self
         
     | 
| 
      
 23 
     | 
    
         
            +
                @slaves = []
         
     | 
| 
      
 24 
     | 
    
         
            +
              end
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              def extension_registered g_parser
         
     | 
| 
      
 27 
     | 
    
         
            +
                super g_parser
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
                <%- @slaves.each do |name, hooks| -%>
         
     | 
| 
      
 30 
     | 
    
         
            +
                @slaves << <%= name %>.new(g_parser, self)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  <%- hooks.each do |hook| -%>
         
     | 
| 
      
 32 
     | 
    
         
            +
                g_parser.hooks[:<%= hook %>].push [@slaves.last, :do_parse]
         
     | 
| 
      
 33 
     | 
    
         
            +
                  <%- end -%>
         
     | 
| 
      
 34 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            <%= @inner_code %>
         
     | 
| 
      
 38 
     | 
    
         
            +
            end
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
            <%= @outer_code %>
         
     | 
| 
         @@ -1,107 +1,113 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
               
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
                 
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            end
         
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
                 
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
                 
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
             
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
                 
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                 
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
             
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
                 
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
             
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                 
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
             
     | 
| 
       58 
     | 
    
         
            -
                 
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
             
     | 
| 
       62 
     | 
    
         
            -
                 
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
             
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
                 
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                 
     | 
| 
       80 
     | 
    
         
            -
                 
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                 
     | 
| 
       83 
     | 
    
         
            -
                 
     | 
| 
       84 
     | 
    
         
            -
                 
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
               
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
                   
     | 
| 
       91 
     | 
    
         
            -
                   
     | 
| 
       92 
     | 
    
         
            -
                 
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
                 
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
             
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            <%- g = g_parser.table.grammar -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            ###
         
     | 
| 
      
 3 
     | 
    
         
            +
            ### <%= target_namespace %> - Part of Depager Extension (slave)
         
     | 
| 
      
 4 
     | 
    
         
            +
            ###
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            module <%= target_namespace %> #:nodoc:all
         
     | 
| 
      
 7 
     | 
    
         
            +
              class <%= target_name %> < Depager::LALR::Basis #:nodoc:all
         
     | 
| 
      
 8 
     | 
    
         
            +
                include Depager::Utils::ExtensionSlaveMethods
         
     | 
| 
      
 9 
     | 
    
         
            +
                <%- @slave_mixins.uniq.each do |i| -%>
         
     | 
| 
      
 10 
     | 
    
         
            +
                include <%=i%>
         
     | 
| 
      
 11 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                ### Reduce Table
         
     | 
| 
      
 14 
     | 
    
         
            +
                REDUCE_TABLE = [
         
     | 
| 
      
 15 
     | 
    
         
            +
                <%- g_parser.table.grammar.rulelist.each do |i| -%>
         
     | 
| 
      
 16 
     | 
    
         
            +
                  [ <%= i.lhs - 1%>, <%= i.rhs.size %> ],
         
     | 
| 
      
 17 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 18 
     | 
    
         
            +
                ]
         
     | 
| 
      
 19 
     | 
    
         
            +
                def reduce_table; REDUCE_TABLE; end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                ### Term to Int
         
     | 
| 
      
 22 
     | 
    
         
            +
                <%- values = (g.nonterms.size ... g.syms.size).map{|i| [ g.syms[i].inspect, i - g.nonterms.size] } -%>
         
     | 
| 
      
 23 
     | 
    
         
            +
                TERM_TO_INT = {
         
     | 
| 
      
 24 
     | 
    
         
            +
                <%- values.each do |k, v| -%>
         
     | 
| 
      
 25 
     | 
    
         
            +
                  <%= k %> => <%= v %>,
         
     | 
| 
      
 26 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 27 
     | 
    
         
            +
                }
         
     | 
| 
      
 28 
     | 
    
         
            +
                def term_to_int; TERM_TO_INT; end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                ### Int to Term
         
     | 
| 
      
 31 
     | 
    
         
            +
                INT_TO_TERM = [
         
     | 
| 
      
 32 
     | 
    
         
            +
                <%- values.each do |k, v| -%>
         
     | 
| 
      
 33 
     | 
    
         
            +
                  <%= k %>,
         
     | 
| 
      
 34 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 35 
     | 
    
         
            +
                ]
         
     | 
| 
      
 36 
     | 
    
         
            +
                def int_to_term; INT_TO_TERM; end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                ### Action Table
         
     | 
| 
      
 39 
     | 
    
         
            +
                ACTION_TABLE = [
         
     | 
| 
      
 40 
     | 
    
         
            +
                <%- g_parser.table.action_table.each do |i| -%>
         
     | 
| 
      
 41 
     | 
    
         
            +
                  [ <% i.each do |j| %><%= j ? "#{j}" : 'nil' %>, <% end %>],
         
     | 
| 
      
 42 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 43 
     | 
    
         
            +
                ]
         
     | 
| 
      
 44 
     | 
    
         
            +
                def action_table; ACTION_TABLE; end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
                ### Default Reduce Table
         
     | 
| 
      
 47 
     | 
    
         
            +
                DEFRED_TABLE = [
         
     | 
| 
      
 48 
     | 
    
         
            +
                <%- g_parser.table.defred_table.each do |i| -%>
         
     | 
| 
      
 49 
     | 
    
         
            +
                  <%= i ? "#{i}" : 'nil' %>,
         
     | 
| 
      
 50 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 51 
     | 
    
         
            +
                ]
         
     | 
| 
      
 52 
     | 
    
         
            +
                def defred_table; DEFRED_TABLE; end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                DEFRED_AFTER_SHIFT_TABLE = [
         
     | 
| 
      
 55 
     | 
    
         
            +
                <%- g_parser.table.defred_after_shift_table.each do |i| -%>
         
     | 
| 
      
 56 
     | 
    
         
            +
                  <%= i ? "#{i}" : 'nil' %>,
         
     | 
| 
      
 57 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 58 
     | 
    
         
            +
                ]
         
     | 
| 
      
 59 
     | 
    
         
            +
                def defred_after_shift_table; DEFRED_AFTER_SHIFT_TABLE; end
         
     | 
| 
      
 60 
     | 
    
         
            +
             
     | 
| 
      
 61 
     | 
    
         
            +
                ### Nonterm to Int
         
     | 
| 
      
 62 
     | 
    
         
            +
                <%- values = (1 ... g.nonterms.size).map{|i| [ ":#{g.syms[i]}", i-1] } -%>
         
     | 
| 
      
 63 
     | 
    
         
            +
                NONTERM_TO_INT = {
         
     | 
| 
      
 64 
     | 
    
         
            +
                <%- values.each do |k, v| -%>
         
     | 
| 
      
 65 
     | 
    
         
            +
                  <%= k %> => <%= v %>,
         
     | 
| 
      
 66 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 67 
     | 
    
         
            +
                }
         
     | 
| 
      
 68 
     | 
    
         
            +
                def nonterm_to_int; NONTERM_TO_INT; end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                ### Int to Nonterm
         
     | 
| 
      
 71 
     | 
    
         
            +
                INT_TO_NONTERM = [
         
     | 
| 
      
 72 
     | 
    
         
            +
                <%- values.each do |k, v| -%>
         
     | 
| 
      
 73 
     | 
    
         
            +
                  <%= k %>,
         
     | 
| 
      
 74 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 75 
     | 
    
         
            +
                ]
         
     | 
| 
      
 76 
     | 
    
         
            +
                def int_to_nonterm; INT_TO_NONTERM; end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                ### Goto Table
         
     | 
| 
      
 79 
     | 
    
         
            +
                GOTO_TABLE = [
         
     | 
| 
      
 80 
     | 
    
         
            +
                <%- g_parser.table.goto_table.each do |i| -%>
         
     | 
| 
      
 81 
     | 
    
         
            +
                  [ <% i.each do |j| %><%= j ? "#{j}" : 'nil' %>, <% end %>],
         
     | 
| 
      
 82 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 83 
     | 
    
         
            +
                ]
         
     | 
| 
      
 84 
     | 
    
         
            +
                def goto_table; GOTO_TABLE; end
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                def initialize g_parser, master
         
     | 
| 
      
 87 
     | 
    
         
            +
                  super()
         
     | 
| 
      
 88 
     | 
    
         
            +
                  @g_parser  = g_parser
         
     | 
| 
      
 89 
     | 
    
         
            +
                  @d_parser  = g_parser.d_parser
         
     | 
| 
      
 90 
     | 
    
         
            +
                  @master    = master
         
     | 
| 
      
 91 
     | 
    
         
            +
                  @decorated = <%= @decorators.inject('self'){|r, i| "#{i.sub(/^@/, '')}.new(#{r})" } %>
         
     | 
| 
      
 92 
     | 
    
         
            +
                end
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                <% if @do_parse_re %>
         
     | 
| 
      
 95 
     | 
    
         
            +
                def do_parse?
         
     | 
| 
      
 96 
     | 
    
         
            +
                  if @line.match(/^\s*<%= @do_parse_re %>/)
         
     | 
| 
      
 97 
     | 
    
         
            +
                    <% if @do_parse_skip %> @line = $' <% end %>
         
     | 
| 
      
 98 
     | 
    
         
            +
                    true
         
     | 
| 
      
 99 
     | 
    
         
            +
                  else
         
     | 
| 
      
 100 
     | 
    
         
            +
                    false
         
     | 
| 
      
 101 
     | 
    
         
            +
                  end
         
     | 
| 
      
 102 
     | 
    
         
            +
                end
         
     | 
| 
      
 103 
     | 
    
         
            +
                <% end %>
         
     | 
| 
      
 104 
     | 
    
         
            +
             
     | 
| 
      
 105 
     | 
    
         
            +
                def banner
         
     | 
| 
      
 106 
     | 
    
         
            +
                  "<%= @banner %> / <%= d_parser.target_namespace %>"
         
     | 
| 
      
 107 
     | 
    
         
            +
                end
         
     | 
| 
      
 108 
     | 
    
         
            +
             
     | 
| 
      
 109 
     | 
    
         
            +
            <%= g_parser.inner_code %>
         
     | 
| 
      
 110 
     | 
    
         
            +
              end
         
     | 
| 
      
 111 
     | 
    
         
            +
            end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
            <%= g_parser.outer_code %>
         
     | 
| 
         @@ -1,117 +1,124 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
             
     | 
| 
       2 
     | 
    
         
            -
             
     | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
       4 
     | 
    
         
            -
             
     | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
               
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
             
     | 
| 
       35 
     | 
    
         
            -
             
     | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
       37 
     | 
    
         
            -
             
     | 
| 
       38 
     | 
    
         
            -
             
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
             
     | 
| 
       41 
     | 
    
         
            -
                 
     | 
| 
       42 
     | 
    
         
            -
             
     | 
| 
       43 
     | 
    
         
            -
             
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                 
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
             
     | 
| 
       48 
     | 
    
         
            -
             
     | 
| 
       49 
     | 
    
         
            -
                 
     | 
| 
       50 
     | 
    
         
            -
             
     | 
| 
       51 
     | 
    
         
            -
             
     | 
| 
       52 
     | 
    
         
            -
             
     | 
| 
       53 
     | 
    
         
            -
                 
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                 
     | 
| 
       58 
     | 
    
         
            -
             
     | 
| 
       59 
     | 
    
         
            -
             
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                 
     | 
| 
       62 
     | 
    
         
            -
             
     | 
| 
       63 
     | 
    
         
            -
             
     | 
| 
       64 
     | 
    
         
            -
                 
     | 
| 
       65 
     | 
    
         
            -
             
     | 
| 
       66 
     | 
    
         
            -
             
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
                 
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
                 
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
             
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
             
     | 
| 
       83 
     | 
    
         
            -
                 
     | 
| 
       84 
     | 
    
         
            -
             
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
       86 
     | 
    
         
            -
             
     | 
| 
       87 
     | 
    
         
            -
             
     | 
| 
       88 
     | 
    
         
            -
             
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
             
     | 
| 
       91 
     | 
    
         
            -
             
     | 
| 
       92 
     | 
    
         
            -
             
     | 
| 
       93 
     | 
    
         
            -
             
     | 
| 
       94 
     | 
    
         
            -
             
     | 
| 
       95 
     | 
    
         
            -
             
     | 
| 
       96 
     | 
    
         
            -
             
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
             
     | 
| 
       99 
     | 
    
         
            -
                 
     | 
| 
       100 
     | 
    
         
            -
             
     | 
| 
       101 
     | 
    
         
            -
             
     | 
| 
       102 
     | 
    
         
            -
             
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
             
     | 
| 
       105 
     | 
    
         
            -
             
     | 
| 
       106 
     | 
    
         
            -
             
     | 
| 
       107 
     | 
    
         
            -
             
     | 
| 
       108 
     | 
    
         
            -
             
     | 
| 
       109 
     | 
    
         
            -
             
     | 
| 
       110 
     | 
    
         
            -
             
     | 
| 
       111 
     | 
    
         
            -
             
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
             
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
             
     | 
| 
       116 
     | 
    
         
            -
             
     | 
| 
       117 
     | 
    
         
            -
             
     | 
| 
      
 1 
     | 
    
         
            +
            <%- g = g_parser.table.grammar -%>
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 3 
     | 
    
         
            +
            <%= @setup_code %>
         
     | 
| 
      
 4 
     | 
    
         
            +
            require 'depager/parser.rb'
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
            <%- @requirements.uniq.each do |i| -%>
         
     | 
| 
      
 7 
     | 
    
         
            +
            <%- if i.match?(/\A'\.\.?\//) -%>
         
     | 
| 
      
 8 
     | 
    
         
            +
            require_relative <%=i%>
         
     | 
| 
      
 9 
     | 
    
         
            +
            <%- else -%>
         
     | 
| 
      
 10 
     | 
    
         
            +
            require <%=i%>
         
     | 
| 
      
 11 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 12 
     | 
    
         
            +
            <%- end -%>
         
     | 
| 
      
 13 
     | 
    
         
            +
             
     | 
| 
      
 14 
     | 
    
         
            +
            <%- r = ''; target_namespace.split('::')[0..-2].each do |i| -%>
         
     | 
| 
      
 15 
     | 
    
         
            +
            module <%= "#{r}#{i}" %> ; end
         
     | 
| 
      
 16 
     | 
    
         
            +
            <%- r << "#{i}::"-%>
         
     | 
| 
      
 17 
     | 
    
         
            +
            <%- end-%>
         
     | 
| 
      
 18 
     | 
    
         
            +
             
     | 
| 
      
 19 
     | 
    
         
            +
            module <%= target_namespace %>
         
     | 
| 
      
 20 
     | 
    
         
            +
              def self.create_decorated_parser(*args)
         
     | 
| 
      
 21 
     | 
    
         
            +
                basis = <%= target_name %>.new(*args)
         
     | 
| 
      
 22 
     | 
    
         
            +
                <%= @decorators.inject("basis"){|r, i| "#{i.tr('@', '') }.new(#{r})" } %>
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              class <%= target_name %> < Depager::LALR::Basis
         
     | 
| 
      
 26 
     | 
    
         
            +
                <%- @mixins.each do |i| -%>
         
     | 
| 
      
 27 
     | 
    
         
            +
                include <%= i %>
         
     | 
| 
      
 28 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                ### Reduce Table
         
     | 
| 
      
 31 
     | 
    
         
            +
                REDUCE_TABLE = [
         
     | 
| 
      
 32 
     | 
    
         
            +
                <%- g_parser.table.grammar.rulelist.each do |i| -%>
         
     | 
| 
      
 33 
     | 
    
         
            +
                  [ <%= '%04s' % (i.lhs - 1)%>, <%= "%04s" % i.rhs.size %> ], # <%= i %>
         
     | 
| 
      
 34 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 35 
     | 
    
         
            +
                ]
         
     | 
| 
      
 36 
     | 
    
         
            +
                def reduce_table; REDUCE_TABLE; end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                ### Term to Int
         
     | 
| 
      
 39 
     | 
    
         
            +
                <%- values = (g.nonterms.size ... g.syms.size).map{|i| [ g.syms[i].inspect, i - g.nonterms.size] } -%>
         
     | 
| 
      
 40 
     | 
    
         
            +
                TERM_TO_INT = {
         
     | 
| 
      
 41 
     | 
    
         
            +
                <%- values.each do |k, v| -%>
         
     | 
| 
      
 42 
     | 
    
         
            +
                  <%= k %> => <%= v %>,
         
     | 
| 
      
 43 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 44 
     | 
    
         
            +
                }
         
     | 
| 
      
 45 
     | 
    
         
            +
                def term_to_int; TERM_TO_INT; end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                ### Int to Term
         
     | 
| 
      
 48 
     | 
    
         
            +
                INT_TO_TERM = [
         
     | 
| 
      
 49 
     | 
    
         
            +
                <%- values.each do |k, v| -%>
         
     | 
| 
      
 50 
     | 
    
         
            +
                  <%= k %>,
         
     | 
| 
      
 51 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 52 
     | 
    
         
            +
                ]
         
     | 
| 
      
 53 
     | 
    
         
            +
                def int_to_term; INT_TO_TERM; end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                ### Action Table
         
     | 
| 
      
 56 
     | 
    
         
            +
                ACTION_TABLE = [
         
     | 
| 
      
 57 
     | 
    
         
            +
                <%- g_parser.table.action_table.each do |i| -%>
         
     | 
| 
      
 58 
     | 
    
         
            +
                  [ <% i.each do |j| %><%= j ? "#{j}" : 'nil' %>, <% end %>],
         
     | 
| 
      
 59 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 60 
     | 
    
         
            +
                ]
         
     | 
| 
      
 61 
     | 
    
         
            +
                def action_table; ACTION_TABLE; end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                ### Default Reduce Table
         
     | 
| 
      
 64 
     | 
    
         
            +
                DEFRED_TABLE = [
         
     | 
| 
      
 65 
     | 
    
         
            +
                <%- g_parser.table.defred_table.each do |i| -%>
         
     | 
| 
      
 66 
     | 
    
         
            +
                  <%= i ? "#{i}" : 'nil' %>,
         
     | 
| 
      
 67 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 68 
     | 
    
         
            +
                ]
         
     | 
| 
      
 69 
     | 
    
         
            +
                def defred_table; DEFRED_TABLE; end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
                DEFRED_AFTER_SHIFT_TABLE = [
         
     | 
| 
      
 72 
     | 
    
         
            +
                <%- g_parser.table.defred_after_shift_table.each do |i| -%>
         
     | 
| 
      
 73 
     | 
    
         
            +
                  <%= i ? "#{i}" : 'nil' %>,
         
     | 
| 
      
 74 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 75 
     | 
    
         
            +
                ]
         
     | 
| 
      
 76 
     | 
    
         
            +
                def defred_after_shift_table; DEFRED_AFTER_SHIFT_TABLE; end
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                ### Nonterm to Int
         
     | 
| 
      
 79 
     | 
    
         
            +
                <%- values = (1 ... g.nonterms.size).map{|i| [ ":#{g.syms[i]}", i-1] } -%>
         
     | 
| 
      
 80 
     | 
    
         
            +
                NONTERM_TO_INT = {
         
     | 
| 
      
 81 
     | 
    
         
            +
                <%- values.each do |k, v| -%>
         
     | 
| 
      
 82 
     | 
    
         
            +
                  <%= k %> => <%= v %>,
         
     | 
| 
      
 83 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 84 
     | 
    
         
            +
                }
         
     | 
| 
      
 85 
     | 
    
         
            +
                def nonterm_to_int; NONTERM_TO_INT; end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
                ### Int to Nonterm
         
     | 
| 
      
 88 
     | 
    
         
            +
                INT_TO_NONTERM = [
         
     | 
| 
      
 89 
     | 
    
         
            +
                <%- values.each do |k, v| -%>
         
     | 
| 
      
 90 
     | 
    
         
            +
                  <%= k %>,
         
     | 
| 
      
 91 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 92 
     | 
    
         
            +
                ]
         
     | 
| 
      
 93 
     | 
    
         
            +
                def int_to_nonterm; INT_TO_NONTERM; end
         
     | 
| 
      
 94 
     | 
    
         
            +
             
     | 
| 
      
 95 
     | 
    
         
            +
                ### Goto Table
         
     | 
| 
      
 96 
     | 
    
         
            +
                GOTO_TABLE = [
         
     | 
| 
      
 97 
     | 
    
         
            +
                <%- g_parser.table.goto_table.each do |i| -%>
         
     | 
| 
      
 98 
     | 
    
         
            +
                  [ <% i.each do |j| %><%= j ? "#{j}" : 'nil' %>, <% end %>],
         
     | 
| 
      
 99 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 100 
     | 
    
         
            +
                ]
         
     | 
| 
      
 101 
     | 
    
         
            +
                def goto_table; GOTO_TABLE; end
         
     | 
| 
      
 102 
     | 
    
         
            +
             
     | 
| 
      
 103 
     | 
    
         
            +
                <%- if Depager.debug_mode? -%>
         
     | 
| 
      
 104 
     | 
    
         
            +
                alias orig_error error
         
     | 
| 
      
 105 
     | 
    
         
            +
                def error
         
     | 
| 
      
 106 
     | 
    
         
            +
                  orig_error
         
     | 
| 
      
 107 
     | 
    
         
            +
                  warn "current state: #{STATE_INFO[@stack.last]}"
         
     | 
| 
      
 108 
     | 
    
         
            +
                end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
                ### States
         
     | 
| 
      
 111 
     | 
    
         
            +
                STATE_INFO = [
         
     | 
| 
      
 112 
     | 
    
         
            +
                  <%- g_parser.table.state_info.each do |s| -%>
         
     | 
| 
      
 113 
     | 
    
         
            +
                  <<'----------',
         
     | 
| 
      
 114 
     | 
    
         
            +
            <%= s.strip %>
         
     | 
| 
      
 115 
     | 
    
         
            +
            ----------
         
     | 
| 
      
 116 
     | 
    
         
            +
                  <%- end -%>
         
     | 
| 
      
 117 
     | 
    
         
            +
                ]
         
     | 
| 
      
 118 
     | 
    
         
            +
                <%- end -%>
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
            <%= g_parser.inner_code + @inner_code %>
         
     | 
| 
      
 121 
     | 
    
         
            +
              end
         
     | 
| 
      
 122 
     | 
    
         
            +
            end
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
            <%= g_parser.outer_code + @outer_code %>
         
     |