ebnf 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/ebnf +3 -3
- data/lib/ebnf/ll1.rb +3 -2
- data/lib/ebnf/parser.rb +17 -3
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7016a2ce8e6c7b23ec669880a9b3f3ddd381793
|
4
|
+
data.tar.gz: 625460a7f6f2c8155960fc5a8640e4b0d854d1cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e09689686d97b44c8845f66129a313006a7264722eb9694b35a675edf2c369b7795f7b3ca6bb6ee82c7567d3be4a752c74b4388b1d57e3f242759eec47e37199
|
7
|
+
data.tar.gz: 6aa62a952f16d3ccd018397a6652b65d3053f68b00c0d0ee767cae3e4686d659e7c5f7e94d89a80a10fdab271ad45e3a733e780372379be5aa7a611ef71b6e46
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.2
|
data/bin/ebnf
CHANGED
@@ -17,10 +17,10 @@ options = {
|
|
17
17
|
:namespace => "http://www.w3.org/ns/formats/Turtle#",
|
18
18
|
}
|
19
19
|
|
20
|
-
out = STDOUT
|
20
|
+
input, out = nil, STDOUT
|
21
21
|
|
22
22
|
OPT_ARGS = [
|
23
|
-
["--
|
23
|
+
["--debug", GetoptLong::NO_ARGUMENT, "Turn on debugging output"],
|
24
24
|
["--bnf", GetoptLong::NO_ARGUMENT, "Transform EBNF to BNF"],
|
25
25
|
["--evaluate","-e", GetoptLong::REQUIRED_ARGUMENT,"Evaluate argument as an EBNF document"],
|
26
26
|
["--ll1", GetoptLong::REQUIRED_ARGUMENT,"Generate First/Follow rules, argument is start symbol"],
|
@@ -53,7 +53,7 @@ opts = GetoptLong.new(*OPT_ARGS.map {|o| o[0..-2]})
|
|
53
53
|
|
54
54
|
opts.each do |opt, arg|
|
55
55
|
case opt
|
56
|
-
when '--
|
56
|
+
when '--debug' then options[:debug] = true
|
57
57
|
when '--bnf' then options[:bnf] = true
|
58
58
|
when '--evaluate' then input = arg
|
59
59
|
when '--input-format' then options[:format] = arg.to_sym
|
data/lib/ebnf/ll1.rb
CHANGED
@@ -285,7 +285,7 @@ module EBNF
|
|
285
285
|
# A First/Follow conflict appears when _eps is in the first
|
286
286
|
# of one rule and there is a token in the first and
|
287
287
|
# follow of the same rule
|
288
|
-
if rule.first.include?(:_eps) && !(overlap = ((rule.first & rule.follow) - [:eps])).empty?
|
288
|
+
if rule.first.include?(:_eps) && !(overlap = ((rule.first & (rule.follow || [])) - [:eps])).empty?
|
289
289
|
error("First/Follow Conflict: #{overlap.first.inspect} is both first and follow of #{rule.sym}")
|
290
290
|
end
|
291
291
|
|
@@ -306,7 +306,8 @@ module EBNF
|
|
306
306
|
# A First/First conflict appears when there are two rules having
|
307
307
|
# the same first, so the parser can't know which one to choose.
|
308
308
|
if branchDict.has_key?(f)
|
309
|
-
|
309
|
+
#require 'byebug'; byebug
|
310
|
+
error("First/First Conflict: #{f.inspect} is the condition for both #{prod_rule.sym} and #{branchDict[f].first}")
|
310
311
|
end
|
311
312
|
|
312
313
|
debug(" alt") {"[#{f}] => #{prod}"}
|
data/lib/ebnf/parser.rb
CHANGED
@@ -18,14 +18,20 @@ module EBNF
|
|
18
18
|
#debug("eachRule(ws)") { "[#{cur_lineno}] #{s.inspect}" }
|
19
19
|
when s = scanner.scan(%r(/\*([^\*]|\*[^\/])*\*/)m)
|
20
20
|
# Eat comments /* .. */
|
21
|
+
cur_lineno += s.count("\n")
|
21
22
|
debug("eachRule(comment)") { "[#{cur_lineno}] #{s.inspect}" }
|
22
23
|
when s = scanner.scan(%r(\(\*([^\*]|\*[^\)])*\*\))m)
|
23
24
|
# Eat comments (* .. *)
|
25
|
+
cur_lineno += s.count("\n")
|
24
26
|
debug("eachRule(comment)") { "[#{cur_lineno}] #{s.inspect}" }
|
25
27
|
when s = scanner.scan(%r((#(?!x)|//).*$))
|
26
|
-
# Eat comments
|
28
|
+
# Eat comments // & #
|
27
29
|
cur_lineno += s.count("\n")
|
28
30
|
debug("eachRule(comment)") { "[#{cur_lineno}] #{s.inspect}" }
|
31
|
+
when s = scanner.scan(/\A["']/)
|
32
|
+
# Found a quote, scan until end of matching quote
|
33
|
+
s += scanner.scan_until(/#{scanner.matched}|$/)
|
34
|
+
r += s
|
29
35
|
when s = scanner.scan(%r(^@terminals))
|
30
36
|
#debug("eachRule(@terminals)") { "[#{cur_lineno}] #{s.inspect}" }
|
31
37
|
yield(r) unless r.empty?
|
@@ -45,8 +51,15 @@ module EBNF
|
|
45
51
|
@lineno = cur_lineno
|
46
52
|
r = s
|
47
53
|
else
|
48
|
-
# Collect until end of line, or start of comment
|
49
|
-
s = scanner.scan_until(%r((
|
54
|
+
# Collect until end of line, or start of comment or quote
|
55
|
+
s = scanner.scan_until(%r{(?:[/\(]\*)|#(?!x)|//|["']|$})
|
56
|
+
if scanner.matched.length > 0
|
57
|
+
# Back up scan head before ending match
|
58
|
+
scanner.pos = scanner.pos - scanner.matched.length
|
59
|
+
|
60
|
+
# Remove matched from end of string
|
61
|
+
s = s[0..-(scanner.matched.length+1)]
|
62
|
+
end
|
50
63
|
cur_lineno += s.count("\n")
|
51
64
|
#debug("eachRule(rest)") { "[#{cur_lineno}] #{s.inspect}" }
|
52
65
|
r += s
|
@@ -268,6 +281,7 @@ module EBNF
|
|
268
281
|
# ((range "^<>'{}|^`") '-\[#x00-#x20\]')
|
269
282
|
def terminal(s)
|
270
283
|
s = s.strip
|
284
|
+
#STDERR.puts s.inspect
|
271
285
|
case m = s[0,1]
|
272
286
|
when '"', "'" # STRING1 or STRING2
|
273
287
|
l, s = s[1..-1].split(m.rstrip, 2)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ebnf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sxp
|
@@ -161,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
161
161
|
requirements:
|
162
162
|
- - ">="
|
163
163
|
- !ruby/object:Gem::Version
|
164
|
-
version:
|
164
|
+
version: 2.2.2
|
165
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
166
|
requirements:
|
167
167
|
- - ">="
|
@@ -169,9 +169,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
171
|
rubyforge_project:
|
172
|
-
rubygems_version: 2.
|
172
|
+
rubygems_version: 2.5.1
|
173
173
|
signing_key:
|
174
174
|
specification_version: 4
|
175
175
|
summary: EBNF parser and parser generator.
|
176
176
|
test_files: []
|
177
|
-
has_rdoc: false
|