depager 0.2.0 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +4 -0
- data/README.en +5 -10
- data/bin/depager +17 -20
- data/examples/c89/c89.tab.rb +5632 -702
- data/examples/pl0d/pl0ds.dr +41 -41
- data/examples/pl0d/pl0ds.tab.rb +1887 -874
- data/examples/sample_calc/calc.action.tab.rb +243 -69
- data/examples/sample_calc/{calc.astl.action.dr → calc.ast.action.dr} +7 -7
- data/examples/sample_calc/calc.ast.action.tab.rb +755 -0
- data/examples/sample_calc/{calc.astl.dr → calc.ast.dr} +7 -7
- data/examples/sample_calc/calc.ast.tab.rb +672 -0
- data/examples/sample_calc/calc.astdf.dr +5 -5
- data/examples/sample_calc/calc.astdf.tab.rb +405 -202
- data/examples/sample_calc/calc.atree.tab.rb +243 -69
- data/examples/sample_calc/calc.cst.tab.rb +275 -109
- data/examples/sample_calc/calc.lex.tab.rb +210 -28
- data/examples/sample_calc/calc.nvaction.tab.rb +251 -77
- data/examples/sample_calc/calc.tab.rb +210 -28
- data/examples/sample_calc/calc_prec.nvaction.tab.rb +224 -50
- data/examples/slex_test/divreg.slex.tab.rb +97 -21
- data/examples/slex_test/ljoin.slex.tab.rb +128 -35
- data/lib/depager.rb +77 -44
- data/lib/depager/{ast_base.dr → ast.dr} +56 -18
- data/lib/depager/{ast_base.rb → ast.rb} +432 -424
- data/lib/depager/astdf.rb +3 -6
- data/lib/depager/atree.rb +54 -62
- data/lib/depager/cst.dr +2 -2
- data/lib/depager/cst.rb +64 -77
- data/lib/depager/grammar.rb +225 -66
- data/lib/depager/lex.dr +1 -1
- data/lib/depager/lex.rb +45 -54
- data/lib/depager/lr.rb +181 -262
- data/lib/depager/lr_put_table.rb +116 -0
- data/lib/depager/nvaction.rb +1 -1
- data/lib/depager/parser.rb +23 -2
- data/lib/depager/slex.dr +3 -3
- data/lib/depager/slex.rb +148 -169
- data/lib/depager/srp.rb +1 -1
- data/lib/depager/template/ast.erbs +69 -0
- data/lib/depager/template/extension_lalr_master.erb +3 -3
- data/lib/depager/template/extension_lalr_slave.erb +7 -7
- data/lib/depager/template/simple.erb +4 -2
- data/lib/depager/template/single_lalr_parser.erb +30 -10
- data/lib/depager/utils.rb +10 -9
- data/lib/depager/version.rb +2 -8
- metadata +10 -11
- data/examples/sample_calc/calc.astl.action.tab.rb +0 -593
- data/examples/sample_calc/calc.astl.tab.rb +0 -501
- data/lib/depager/astl.rb +0 -14
- data/lib/depager/template/astdf.erbs +0 -57
- data/lib/depager/template/astl.erbs +0 -57
data/lib/depager/astl.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'depager/ast_base.rb'
|
2
|
-
class ASTBuilderLazyExtension < ASTBuilderBaseExtension #:nodoc:all
|
3
|
-
def modify_action_code code, nodes=[]
|
4
|
-
code.gsub(/~([a-z_])/, 'node.\1')
|
5
|
-
end
|
6
|
-
def gen_accept_code sym
|
7
|
-
%{
|
8
|
-
def _#{sym}_ v
|
9
|
-
@#{sym}.accept(v); @#{sym}
|
10
|
-
end
|
11
|
-
}; #code
|
12
|
-
end
|
13
|
-
Template = CodeUtils::make_tmpl("#{Depager::Tmpldir}/astl.erbs")
|
14
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
===:defnode
|
2
|
-
class Node
|
3
|
-
attr_accessor :lineno
|
4
|
-
attr_accessor <%= _opt_attr.map{|i| ":#{i}" }.join(', ') %>
|
5
|
-
<%= ini %>
|
6
|
-
def to_ary
|
7
|
-
[self]
|
8
|
-
end
|
9
|
-
def self.[] lineno, *args
|
10
|
-
self.new lineno, *args
|
11
|
-
end
|
12
|
-
def accept v
|
13
|
-
end
|
14
|
-
end
|
15
|
-
require 'forwardable'
|
16
|
-
class NodeList < Node
|
17
|
-
attr_accessor :lineno
|
18
|
-
extend Forwardable
|
19
|
-
_methods = Array.instance_methods -
|
20
|
-
Object.instance_methods -
|
21
|
-
['push', 'concat', 'to_ary', 'map']
|
22
|
-
def_delegators(:@lst, *_methods)
|
23
|
-
def initialize(lineno, lst=[])
|
24
|
-
@lineno = lineno
|
25
|
-
@lst = lst.to_a
|
26
|
-
end
|
27
|
-
<%=
|
28
|
-
_opt_attr.map {|i| ;%{
|
29
|
-
def #{i}
|
30
|
-
@lst.map{|i| "i.#{i}"}
|
31
|
-
end
|
32
|
-
}}.join("\n ")
|
33
|
-
%>
|
34
|
-
def push(i) @lst.push i; self; end
|
35
|
-
def concat(i) @lst.concat i; self; end
|
36
|
-
def map(&b) @lst.map(&b); end
|
37
|
-
def to_ary() @lst; end
|
38
|
-
def accept(v)
|
39
|
-
@lst.each{|i| i.accept(v) }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
===:node
|
43
|
-
class Node_<%= name %> < Node
|
44
|
-
attr_accessor <%= nodes.map{|i| ":#{i}" }.join(', ') %>
|
45
|
-
attr_accessor <%= attrs.map{|i| ":#{i}" }.join(', ') %>
|
46
|
-
def initialize <%= nodes.unshift('lineno').join(', ') %>
|
47
|
-
super()
|
48
|
-
@lineno = lineno
|
49
|
-
<%= nodes.map{|i| " @#{i} = #{i}\n"} %>
|
50
|
-
end
|
51
|
-
def accept v
|
52
|
-
warn @lineno.to_s+':'+self.class.to_s if $DEBUG
|
53
|
-
<%= accept %>
|
54
|
-
v.visit_Node_<%= name %>(self)
|
55
|
-
self
|
56
|
-
end
|
57
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
===:defnode
|
2
|
-
class Node
|
3
|
-
attr_accessor :lineno
|
4
|
-
attr_accessor <%= _opt_attr.map{|i| ":#{i}" }.join(', ') %>
|
5
|
-
<%= ini %>
|
6
|
-
def to_ary
|
7
|
-
[self]
|
8
|
-
end
|
9
|
-
def self.[] lineno, *args
|
10
|
-
self.new lineno, *args
|
11
|
-
end
|
12
|
-
def accept v
|
13
|
-
end
|
14
|
-
end
|
15
|
-
require 'forwardable'
|
16
|
-
class NodeList < Node
|
17
|
-
attr_accessor :lineno
|
18
|
-
extend Forwardable
|
19
|
-
_methods = Array.instance_methods -
|
20
|
-
Object.instance_methods -
|
21
|
-
['push', 'concat', 'to_ary', 'map']
|
22
|
-
def_delegators(:@lst, *_methods)
|
23
|
-
def initialize(lineno, lst=[])
|
24
|
-
@lineno = lineno
|
25
|
-
@lst = lst.to_a
|
26
|
-
end
|
27
|
-
<%=
|
28
|
-
_opt_attr.map {|i| ;%{
|
29
|
-
def #{i}
|
30
|
-
@lst.map{|i| "i.#{i}"}
|
31
|
-
end
|
32
|
-
}}.join("\n ")
|
33
|
-
%>
|
34
|
-
def push(i) @lst.push i; self; end
|
35
|
-
def concat(i) @lst.concat i; self; end
|
36
|
-
def map(&b) @lst.map(&b); end
|
37
|
-
def to_ary() @lst; end
|
38
|
-
def accept(v)
|
39
|
-
@lst.each{|i| i.accept(v) }
|
40
|
-
end
|
41
|
-
end
|
42
|
-
===:node
|
43
|
-
class Node_<%= name %> < Node
|
44
|
-
attr_accessor <%= nodes.map{|i| ":#{i}" }.join(', ') %>
|
45
|
-
attr_accessor <%= attrs.map{|i| ":#{i}" }.join(', ') %>
|
46
|
-
def initialize <%= nodes.unshift('lineno').join(', ') %>
|
47
|
-
super()
|
48
|
-
@lineno = lineno
|
49
|
-
<%= nodes.map{|i| " @#{i} = #{i}\n"} %>
|
50
|
-
end
|
51
|
-
<%= accept %>
|
52
|
-
def accept v
|
53
|
-
warn @lineno.to_s+':'+self.class.to_s if $DEBUG
|
54
|
-
v.visit_Node_<%= name %>(self)
|
55
|
-
self
|
56
|
-
end
|
57
|
-
end
|