depager 0.3.0.b20160729 → 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 +5 -5
- 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 +4 -3
- data/README.ja +4 -47
- data/Rakefile +31 -0
- data/bin/depager +3 -38
- data/examples/action_pl0d/pl0d.action.dr +4 -4
- data/examples/action_pl0d/test.pl0ds +2 -3
- data/examples/c89/c89.dr +4 -4
- data/examples/c89/test.c89 +1 -1
- data/examples/extension/astdf.rb +4 -5
- data/examples/extension/atree.dr +3 -3
- data/examples/extension/calc.atree.dr +4 -4
- data/examples/extension/calc.simple_action.dr +3 -3
- data/examples/extension/paction.dr +3 -3
- data/examples/extension/pactiontest.dr +3 -3
- data/examples/extension/simple_action.rb +26 -24
- data/examples/pl0d/pl0ds.dr +5 -5
- data/examples/pl0d/test.pl0ds +2 -2
- data/examples/rie_calc/calc.rie.dr +4 -4
- data/examples/rie_dcuse/dcuse.rie.dr +4 -4
- data/examples/rie_pl0/pl0.rie.dr +3 -3
- data/examples/slex_test/divreg.slex.dr +5 -5
- data/examples/slex_test/ljoin.slex.dr +5 -5
- data/examples/{sample_calc → tiny_calc}/calc.action.dr +4 -4
- data/examples/{sample_calc → tiny_calc}/calc.ast.action.dr +20 -9
- data/examples/{sample_calc → tiny_calc}/calc.ast.dr +19 -7
- data/examples/{sample_calc → tiny_calc}/calc.cst.dr +12 -7
- data/examples/{sample_calc → tiny_calc}/calc.dr +1 -1
- data/examples/{sample_calc → tiny_calc}/calc.lex.dr +2 -2
- data/examples/{sample_calc → tiny_calc}/calc_prec.action.dr +4 -4
- data/lib/depager/cli.rb +44 -0
- data/lib/depager/grammar.rb +72 -75
- data/lib/depager/lr.rb +169 -154
- data/lib/depager/parser.rb +90 -103
- data/lib/depager/plugins/_rie_debug.rb +63 -0
- data/lib/depager/plugins/action.rb +47 -0
- data/lib/depager/{ruby/plugins → plugins}/ast.dr +20 -17
- data/lib/depager/{ruby/plugins → plugins}/ast.rb +266 -304
- data/lib/depager/{ruby/plugins → plugins}/cst.dr +18 -16
- data/lib/depager/{ruby/plugins → plugins}/cst.rb +152 -148
- data/lib/depager/{ruby/plugins → plugins}/lex.dr +7 -7
- data/lib/depager/{ruby/plugins → plugins}/lex.rb +72 -69
- data/lib/depager/{ruby/plugins → plugins}/rie.dr +12 -10
- data/lib/depager/{ruby/plugins → plugins}/rie.rb +224 -263
- data/lib/depager/{ruby/plugins → plugins}/slex.dr +13 -14
- data/lib/depager/{ruby/plugins → plugins}/slex.rb +183 -194
- data/lib/depager/plugins/srp.rb +46 -0
- data/lib/depager/ruby/templates/extension_lalr_master.erb +6 -12
- data/lib/depager/ruby/templates/extension_lalr_slave.erb +31 -17
- data/lib/depager/ruby/templates/single_lalr_parser.erb +35 -26
- data/lib/depager/utils.rb +56 -46
- data/lib/depager/version.rb +1 -2
- data/lib/depager.rb +166 -176
- metadata +38 -33
- data/lib/depager/ruby/plugins/_rie_debug.rb +0 -35
- data/lib/depager/ruby/plugins/action.rb +0 -53
- data/lib/depager/ruby/plugins/srp.rb +0 -56
- /data/examples/{sample_calc → tiny_calc}/test.calc +0 -0
@@ -1,9 +1,8 @@
|
|
1
1
|
%defext Depager::StatefulLexerExtension
|
2
|
-
%extend Depager::Depager::Lexer ('plugins/lex.rb')
|
3
|
-
%extend Depager::Depager::Action ('plugins/action.rb')
|
2
|
+
%extend Depager::Depager::Lexer ('depager/plugins/lex.rb')
|
3
|
+
%extend Depager::Depager::Action ('depager/plugins/action.rb')
|
4
4
|
%decorate @Action
|
5
|
-
#%decorate Depager::LALR::ShiftReducePrinter ('plugins/srp.rb')
|
6
|
-
%expanded_code_delimiter DEPAGER_EXPANDED_CODE
|
5
|
+
#%decorate Depager::LALR::ShiftReducePrinter ('depager/plugins/srp.rb')
|
7
6
|
%inner{
|
8
7
|
attr_accessor :ins, :code, :optval
|
9
8
|
def init_extension
|
@@ -14,11 +13,11 @@
|
|
14
13
|
end
|
15
14
|
|
16
15
|
def term_extension
|
17
|
-
@action_code <<
|
16
|
+
@action_code << <<-CODE
|
18
17
|
def after_error
|
19
18
|
warn "StatefulLex: lex_state==\#{@basis.lex_state}" if Depager.debug_mode?
|
20
19
|
end
|
21
|
-
|
20
|
+
CODE
|
22
21
|
g_parser.outer_code <<
|
23
22
|
generate_action_decorator_code(@on_reduce, @action_code)
|
24
23
|
end
|
@@ -53,11 +52,11 @@
|
|
53
52
|
else
|
54
53
|
end
|
55
54
|
end
|
56
|
-
@action_code <<
|
55
|
+
@action_code << <<-CODE
|
57
56
|
def #{m_name} val
|
58
57
|
#{codes.join("\n ")}
|
59
58
|
end
|
60
|
-
|
59
|
+
CODE
|
61
60
|
end
|
62
61
|
@ins.clear
|
63
62
|
end
|
@@ -104,7 +103,7 @@
|
|
104
103
|
else
|
105
104
|
'raise RuntimeError, "must not happen #{@line}"'
|
106
105
|
end
|
107
|
-
ll <<
|
106
|
+
ll << <<-CODE
|
108
107
|
def lex_#{m}(&block)
|
109
108
|
case @line
|
110
109
|
#{l}
|
@@ -112,9 +111,9 @@
|
|
112
111
|
#{else_code}
|
113
112
|
end
|
114
113
|
end
|
115
|
-
|
114
|
+
CODE
|
116
115
|
end
|
117
|
-
g_parser.inner_code << ll <<
|
116
|
+
g_parser.inner_code << ll << <<-CODE
|
118
117
|
attr_accessor :lex_state, :lex_context
|
119
118
|
def lex(&block)
|
120
119
|
@lex_state ||= :START
|
@@ -126,7 +125,7 @@
|
|
126
125
|
end while @original_line = @line = file.gets
|
127
126
|
yield nil, nil
|
128
127
|
end
|
129
|
-
|
128
|
+
CODE
|
130
129
|
}
|
131
130
|
;
|
132
131
|
mode_list:
|
@@ -147,11 +146,11 @@
|
|
147
146
|
lexact:
|
148
147
|
lexlist opt_noskip ACTION
|
149
148
|
{
|
150
|
-
|
149
|
+
<<-CODE
|
151
150
|
when #{_lexlist.join(', ')}
|
152
151
|
#{ _opt_noskip ? '#' : "@line = $'" }
|
153
152
|
#{ _ACTION.value }
|
154
|
-
|
153
|
+
CODE
|
155
154
|
}
|
156
155
|
;
|
157
156
|
opt_noskip:
|