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.
@@ -1,9 +0,0 @@
1
- module Furnace
2
- module Code
3
- class TerminalToken < Token
4
- def to_structure(options={})
5
- structurize to_text, options
6
- end
7
- end
8
- end
9
- end
@@ -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"