antelope 0.1.9 → 0.1.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/lib/antelope/generation/recognizer.rb +1 -1
- data/lib/antelope/template/scanner.rb +16 -21
- data/lib/antelope/version.rb +1 -1
- data/spec/antelope/ace/compiler_spec.rb +1 -1
- data/spec/antelope/ace/scanner_spec.rb +2 -2
- data/spec/antelope/constructor_spec.rb +14 -9
- data/spec/antelope/template_spec.rb +2 -2
- data/spec/fixtures/simple.ace +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 589dbe0a0efbde62a5437b07ade45e68dc624d13
|
4
|
+
data.tar.gz: 2b3e774c00a75aa76bb37288621c5d6e094dc9ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e0ab4508a37e1d0d32ec8a3c715d8ba3117e8a94b3aa370e16ec8a22d2183c86f4ad2c290d89c18736e3f10d120412922e0eb0466aec79c36dabcaf2aac354c3
|
7
|
+
data.tar.gz: 95c5614a000b96260bc277cc8cfff24505fb8d5ae6d7780ededb1178f92c3bce97525961004ee63f54ea319901add91f6a63abf68a0fd9c559680aedd014de56
|
data/.travis.yml
CHANGED
@@ -118,7 +118,7 @@ module Antelope
|
|
118
118
|
rules = state.rules.
|
119
119
|
select { |r| r.active == active && r.succ? }.
|
120
120
|
map(&:succ).to_set
|
121
|
-
s = states.find { |st| rules
|
121
|
+
s = states.find { |st| rules.subset? st.rules } || begin
|
122
122
|
s = State.new << rules
|
123
123
|
compute_closure(s)
|
124
124
|
states << s
|
@@ -21,7 +21,7 @@ module Antelope
|
|
21
21
|
@line = 1
|
22
22
|
@scanner.pos = 0
|
23
23
|
until @scanner.eos?
|
24
|
-
scan_tag || scan_until_tag ||
|
24
|
+
scan_tag || scan_until_tag || scan_until_end
|
25
25
|
end
|
26
26
|
|
27
27
|
@tokens
|
@@ -30,7 +30,7 @@ module Antelope
|
|
30
30
|
rescue SyntaxError => e
|
31
31
|
start = [@scanner.pos - 8, 0].max
|
32
32
|
stop = [@scanner.pos + 8, @scanner.string.length].min
|
33
|
-
snip = @scanner.string[start..stop].
|
33
|
+
snip = @scanner.string[start..stop].inspect
|
34
34
|
char = @scanner.string[@scanner.pos]
|
35
35
|
char = if char
|
36
36
|
char.inspect
|
@@ -38,8 +38,8 @@ module Antelope
|
|
38
38
|
"EOF"
|
39
39
|
end
|
40
40
|
|
41
|
-
new_line = "#{@source}:#{@line}
|
42
|
-
"(near #{snip})"
|
41
|
+
new_line = "#{@source}:#{@line}:#{@scanner.pos}: "\
|
42
|
+
"unexpected #{char} (near #{snip})"
|
43
43
|
|
44
44
|
raise e, e.message, [new_line, *e.backtrace]
|
45
45
|
end
|
@@ -47,41 +47,36 @@ module Antelope
|
|
47
47
|
private
|
48
48
|
|
49
49
|
def scan_until_tag
|
50
|
-
|
50
|
+
case
|
51
|
+
when value = @scanner.scan_until(/(\%|\{|\}|\\)/)
|
51
52
|
@scanner.pos -= 1
|
52
53
|
tokens << [:text, value[0..-2]]
|
53
54
|
end
|
54
55
|
end
|
55
56
|
|
57
|
+
def scan_until_end
|
58
|
+
tokens << [:text, @scanner.scan(/.+/m)]
|
59
|
+
end
|
60
|
+
|
56
61
|
def scan_tag
|
57
62
|
case
|
58
63
|
when @scanner.scan(/\\(\{\{|\}\}|\%)/)
|
59
64
|
tokens << [:text, @scanner[1]]
|
60
|
-
when @scanner.scan(
|
61
|
-
update_line
|
62
|
-
tokens << [:newline] if @scanner[0][0] == "\n"
|
65
|
+
when @scanner.scan(/\%\{/)
|
63
66
|
scan_tag_start(:output_tag, :_, /\}/)
|
64
|
-
when @scanner.scan(
|
65
|
-
update_line
|
66
|
-
error! unless value = @scanner.scan_until(/\n/)
|
67
|
-
@scanner.pos -= 1
|
67
|
+
when @scanner.scan(/\%/)
|
68
68
|
tokens << [:tag, value]
|
69
|
-
when @scanner.scan(/\
|
69
|
+
when @scanner.scan(/\{\{=/)
|
70
70
|
update_line
|
71
71
|
scan_tag_start(:output_tag)
|
72
|
-
when @scanner.scan(/\
|
72
|
+
when @scanner.scan(/\{\{!/)
|
73
73
|
update_line
|
74
74
|
scan_tag_start(:comment_tag)
|
75
|
-
when @scanner.scan(/\
|
76
|
-
update_line
|
75
|
+
when @scanner.scan(/\{\{/)
|
77
76
|
scan_tag_start(:tag)
|
78
|
-
when @scanner.scan(/\
|
79
|
-
update_line
|
77
|
+
when @scanner.scan(/\}\}/)
|
80
78
|
@scanner.pos -= 2
|
81
79
|
error!
|
82
|
-
when @scanner.scan(/\n/)
|
83
|
-
update_line
|
84
|
-
tokens << [:newline]
|
85
80
|
when @scanner.scan(/\{|\}|\%|\\/)
|
86
81
|
tokens << [:text, @scanner[0]]
|
87
82
|
else
|
data/lib/antelope/version.rb
CHANGED
@@ -4,8 +4,8 @@ describe Ace::Scanner do
|
|
4
4
|
expect(scan("%test \"a\" hi\n%%\nt: d { { } }\n%%\nhi\n")).to eq [
|
5
5
|
[:directive, "test", ["a", "hi"]],
|
6
6
|
[:second],
|
7
|
-
[:label, "t"],
|
8
|
-
[:part, "d"],
|
7
|
+
[:label, "t", nil],
|
8
|
+
[:part, "d", nil],
|
9
9
|
[:block, "{ { } }"],
|
10
10
|
[:third],
|
11
11
|
[:copy, "\nhi\n"]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
describe Generation::Constructor do
|
2
2
|
let(:grammar) { double("grammar") }
|
3
3
|
let(:terminal) { token(:TERMINAL) }
|
4
|
-
let(:epsilon) { token(
|
4
|
+
let(:epsilon) { token(:epsilon) }
|
5
5
|
|
6
6
|
subject { described_class.new(grammar) }
|
7
7
|
|
@@ -73,7 +73,7 @@ describe Generation::Constructor do
|
|
73
73
|
end
|
74
74
|
|
75
75
|
context "when given an array" do
|
76
|
-
let(:terminal2) { token(:TERMINAL2) }
|
76
|
+
let(:terminal2) { token(:terminal, :TERMINAL2) }
|
77
77
|
|
78
78
|
it "generates a set" do
|
79
79
|
expect(subject.first([epsilon, terminal])).
|
@@ -85,11 +85,14 @@ describe Generation::Constructor do
|
|
85
85
|
|
86
86
|
context "when given a nonterminal" do
|
87
87
|
let(:grammar) { with_recognizer }
|
88
|
-
let(:nonterminal) { token(:
|
88
|
+
let(:nonterminal) { token(:nonterminal, :e) }
|
89
89
|
|
90
|
+
before do
|
91
|
+
p grammar.terminals
|
92
|
+
end
|
90
93
|
it "generates a set" do
|
91
94
|
expect(subject.first(nonterminal)).
|
92
|
-
to eq [token(:IDENT), token(:STAR, "*")].to_set
|
95
|
+
to eq [token(:terminal, :IDENT), token(:terminal, :STAR, "*")].to_set
|
93
96
|
end
|
94
97
|
end
|
95
98
|
|
@@ -109,7 +112,7 @@ describe Generation::Constructor do
|
|
109
112
|
|
110
113
|
context "when given a nonterminal" do
|
111
114
|
let(:grammar) { with_recognizer }
|
112
|
-
let(:nonterminal) { token(:
|
115
|
+
let(:nonterminal) { token(:nonterminal, :l) }
|
113
116
|
|
114
117
|
before do
|
115
118
|
subject.productions.merge grammar.productions.values.flatten
|
@@ -117,15 +120,17 @@ describe Generation::Constructor do
|
|
117
120
|
|
118
121
|
it "generates a set" do
|
119
122
|
expect(subject.follow(nonterminal)).to eq [
|
120
|
-
token(:EQUALS, "="),
|
121
|
-
token(:"$")
|
123
|
+
token(:terminal, :EQUALS, "="),
|
124
|
+
token(:terminal, :"$end")
|
122
125
|
].to_set
|
123
126
|
end
|
124
127
|
end
|
125
128
|
end
|
126
129
|
|
127
|
-
|
130
|
+
|
131
|
+
|
132
|
+
def token(type, name = nil, value = nil, ttype = nil, id = nil)
|
128
133
|
type = Ace::Token.const_get(type.to_s.capitalize)
|
129
|
-
type.new(name, value)
|
134
|
+
type.new(name, ttype, id, value)
|
130
135
|
end
|
131
136
|
end
|
data/spec/fixtures/simple.ace
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: antelope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Rodi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: hashie
|