furnace 0.3.0.beta1 → 0.3.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -2
- data/.yardopts +1 -0
- data/Gemfile +1 -0
- data/Rakefile +12 -1
- data/furnace.gemspec +3 -0
- data/lib/furnace/ast/node.rb +102 -17
- data/lib/furnace/ast/{strict_visitor.rb → processor.rb} +4 -4
- data/lib/furnace/ast.rb +17 -8
- data/lib/furnace/cfg/algorithms.rb +193 -0
- data/lib/furnace/cfg/graph.rb +5 -187
- data/lib/furnace/cfg.rb +5 -4
- data/lib/furnace/version.rb +1 -1
- data/lib/furnace.rb +7 -9
- data/test/ast_test.rb +166 -0
- data/test/test_helper.rb +36 -0
- metadata +43 -15
- data/lib/furnace/ast/matcher/dsl.rb +0 -50
- data/lib/furnace/ast/matcher/special.rb +0 -20
- data/lib/furnace/ast/matcher.rb +0 -198
- data/lib/furnace/ast/visitor.rb +0 -50
- data/lib/furnace/code/newline_token.rb +0 -9
- data/lib/furnace/code/nonterminal_token.rb +0 -16
- data/lib/furnace/code/separated_token.rb +0 -17
- data/lib/furnace/code/surrounded_token.rb +0 -21
- data/lib/furnace/code/terminal_token.rb +0 -9
- data/lib/furnace/code/token.rb +0 -73
- data/lib/furnace/code.rb +0 -10
data/lib/furnace/code/token.rb
DELETED
@@ -1,73 +0,0 @@
|
|
1
|
-
module Furnace
|
2
|
-
module Code
|
3
|
-
class Token
|
4
|
-
attr_reader :origin
|
5
|
-
|
6
|
-
def initialize(origin, options={})
|
7
|
-
@origin, @options = origin, options
|
8
|
-
@waiters = []
|
9
|
-
end
|
10
|
-
|
11
|
-
def self.type
|
12
|
-
@type ||= name.sub(/^.*::/, '').sub(/Token$/, '').to_sym
|
13
|
-
end
|
14
|
-
|
15
|
-
def type
|
16
|
-
self.class.type
|
17
|
-
end
|
18
|
-
|
19
|
-
def subscribe(proc)
|
20
|
-
@waiters << proc
|
21
|
-
end
|
22
|
-
|
23
|
-
def unsubscribe(proc)
|
24
|
-
@waiters.delete proc
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_text
|
28
|
-
raise "Reimplement Token#to_text in a subclass"
|
29
|
-
end
|
30
|
-
|
31
|
-
def to_structure(options={})
|
32
|
-
structurize nil, options
|
33
|
-
end
|
34
|
-
|
35
|
-
protected
|
36
|
-
|
37
|
-
def indent(code, options=@options)
|
38
|
-
unless code.empty?
|
39
|
-
code.to_s.gsub(/^/, (options[:indent_with] || ' ') * (options[:level] || 1))
|
40
|
-
else
|
41
|
-
""
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def structurize(comment, options)
|
46
|
-
options = { level: 0 }.merge(options)
|
47
|
-
|
48
|
-
structure = indent(type, options)
|
49
|
-
|
50
|
-
if comment
|
51
|
-
structure = structure.ljust(options[:describe_at] || 50)
|
52
|
-
|
53
|
-
if comment =~ /^\s+$/
|
54
|
-
structure += " <whitespace>"
|
55
|
-
else
|
56
|
-
structure += " ; #{comment.gsub(%r{\/\*.*?\*\/}, '').
|
57
|
-
gsub(/[ \t]+/, ' ').gsub("\n", '')}"
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
structure += "\n"
|
62
|
-
|
63
|
-
if @children
|
64
|
-
structure += @children.map do |child|
|
65
|
-
child.to_structure(options.merge(:level => options[:level] + 1))
|
66
|
-
end.join
|
67
|
-
end
|
68
|
-
|
69
|
-
structure
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
data/lib/furnace/code.rb
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
require "set"
|
2
|
-
|
3
|
-
require "furnace"
|
4
|
-
|
5
|
-
require "furnace/code/token"
|
6
|
-
require "furnace/code/terminal_token"
|
7
|
-
require "furnace/code/nonterminal_token"
|
8
|
-
require "furnace/code/surrounded_token"
|
9
|
-
require "furnace/code/separated_token"
|
10
|
-
require "furnace/code/newline_token"
|