furnace 0.0.6 → 0.0.7
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.
- data/LICENSE +20 -0
- data/lib/furnace/code/nonterminal_token.rb +16 -0
- data/lib/furnace/code/separated_token.rb +17 -0
- data/lib/furnace/code/surrounded_token.rb +21 -0
- data/lib/furnace/code/terminal_token.rb +9 -0
- data/lib/furnace/code/token.rb +73 -0
- data/lib/furnace/code.rb +10 -0
- data/lib/furnace/version.rb +1 -1
- data/lib/furnace.rb +1 -0
- metadata +10 -4
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011-2012 Peter Zotov <whitequark@whitequark.org>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a
|
4
|
+
copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included
|
12
|
+
in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
15
|
+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
17
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
18
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
19
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
20
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Furnace
|
2
|
+
module Code
|
3
|
+
class NonterminalToken < Token
|
4
|
+
attr_reader :children
|
5
|
+
|
6
|
+
def initialize(origin, children, options={})
|
7
|
+
super(origin, options)
|
8
|
+
@children = children.compact
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_text
|
12
|
+
children.map(&:to_text).join
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Furnace
|
2
|
+
module Code
|
3
|
+
class SeparatedToken < NonterminalToken
|
4
|
+
def text_between
|
5
|
+
""
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_text
|
9
|
+
"#{text_before}#{children.map(&:to_text).join(text_between)}#{text_after}"
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_structure(options={})
|
13
|
+
structurize "#{text_before} #{([text_between] * 3).join(" ")} #{text_after}", options
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Furnace
|
2
|
+
module Code
|
3
|
+
class SurroundedToken < NonterminalToken
|
4
|
+
def text_before
|
5
|
+
""
|
6
|
+
end
|
7
|
+
|
8
|
+
def text_after
|
9
|
+
""
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_text
|
13
|
+
"#{text_before}#{children.map(&:to_text).join}#{text_after}"
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_structure(options={})
|
17
|
+
structurize "#{text_before} ... #{text_after}", options
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,73 @@
|
|
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)
|
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
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "set"
|
2
|
+
|
3
|
+
require "furnace/base"
|
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"
|
data/lib/furnace/version.rb
CHANGED
data/lib/furnace.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: furnace
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Furnace is a static code analysis framework for dynamic languages, aimed
|
15
15
|
at efficient type and behavior inference.
|
@@ -23,6 +23,7 @@ files:
|
|
23
23
|
- .gitignore
|
24
24
|
- .rvmrc
|
25
25
|
- Gemfile
|
26
|
+
- LICENSE
|
26
27
|
- Rakefile
|
27
28
|
- bin/furnace
|
28
29
|
- furnace.gemspec
|
@@ -46,6 +47,12 @@ files:
|
|
46
47
|
- lib/furnace/cfg/edge.rb
|
47
48
|
- lib/furnace/cfg/graph.rb
|
48
49
|
- lib/furnace/cfg/node.rb
|
50
|
+
- lib/furnace/code.rb
|
51
|
+
- lib/furnace/code/nonterminal_token.rb
|
52
|
+
- lib/furnace/code/separated_token.rb
|
53
|
+
- lib/furnace/code/surrounded_token.rb
|
54
|
+
- lib/furnace/code/terminal_token.rb
|
55
|
+
- lib/furnace/code/token.rb
|
49
56
|
- lib/furnace/graphviz.rb
|
50
57
|
- lib/furnace/transform.rb
|
51
58
|
- lib/furnace/transform/generic/anf_build.rb
|
@@ -77,9 +84,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
84
|
version: '0'
|
78
85
|
requirements: []
|
79
86
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.8.
|
87
|
+
rubygems_version: 1.8.17
|
81
88
|
signing_key:
|
82
89
|
specification_version: 3
|
83
90
|
summary: A static code analysis framework
|
84
91
|
test_files: []
|
85
|
-
has_rdoc:
|