ebnf 0.3.6 → 0.3.7
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 -27
- data/etc/turtle.rb +1 -1
- data/lib/ebnf/base.rb +29 -0
- data/lib/ebnf/ll1/lexer.rb +3 -1
- metadata +24 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83c6af2a26c41f53c79e1bb289e35b261eb1eb1a
|
4
|
+
data.tar.gz: 8dabfd9d6025e868446389aa584bfd5c7a94f43a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4878eb173f39de9e69acdbcc6547d0ce3c022cdad2fd4fa944029f93dde53749e874707fee4aa9aa66c70089d7270a5148bcde3386dda14bc61338fe70172293
|
7
|
+
data.tar.gz: 47cf8d873b75110c9cdd051c7178fe3bc287272074ea0f30ff39d3c6981e369d31dce1bbdadfcb1b718b5a5e51dd515449771b3d93ff0b30fc28cf090c74b8a4
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.7
|
data/bin/ebnf
CHANGED
@@ -11,30 +11,6 @@ require 'rubygems'
|
|
11
11
|
require 'getoptlong'
|
12
12
|
require 'ebnf'
|
13
13
|
|
14
|
-
def dump_tables(grammarFile, ebnf, output, options)
|
15
|
-
ebnf.build_tables
|
16
|
-
unless output == STDOUT
|
17
|
-
output.puts "# This file is automatically generated by #{__FILE__}"
|
18
|
-
output.puts "# BRANCH derived from #{grammarFile}"
|
19
|
-
unless ebnf.errors.empty?
|
20
|
-
output.puts "# Note, tables completed with errors, may need to be resolved manually:"
|
21
|
-
#output.puts "# #{pp.conflicts.map{|c| c.join("\n# ")}.join("\n# ")}"
|
22
|
-
end
|
23
|
-
output.puts "module #{options.fetch(:mod_name, 'Branch')}"
|
24
|
-
output.puts " START = #{ebnf.start.inspect}"
|
25
|
-
output.puts
|
26
|
-
end
|
27
|
-
ebnf.outputTable(output, 'BRANCH', ebnf.branch, 1)
|
28
|
-
ebnf.outputTable(output, 'TERMINALS', ebnf.terminals, 1)
|
29
|
-
ebnf.outputTable(output, 'FIRST', ebnf.first, 1)
|
30
|
-
ebnf.outputTable(output, 'FOLLOW', ebnf.follow, 1)
|
31
|
-
ebnf.outputTable(output, 'PASS', [ebnf.pass], 1) if ebnf.pass
|
32
|
-
unless output == STDOUT
|
33
|
-
output.puts "end"
|
34
|
-
end
|
35
|
-
""
|
36
|
-
end
|
37
|
-
|
38
14
|
options = {
|
39
15
|
:output_format => :sxp,
|
40
16
|
:prefix => "ttl",
|
@@ -46,14 +22,14 @@ out = STDOUT
|
|
46
22
|
OPT_ARGS = [
|
47
23
|
["--dbg", GetoptLong::NO_ARGUMENT, "Turn on debugging output"],
|
48
24
|
["--bnf", GetoptLong::NO_ARGUMENT, "Transform EBNF to BNF"],
|
49
|
-
["--evaluate","-e", GetoptLong::REQUIRED_ARGUMENT,"Evaluate argument as
|
25
|
+
["--evaluate","-e", GetoptLong::REQUIRED_ARGUMENT,"Evaluate argument as an EBNF document"],
|
50
26
|
["--ll1", GetoptLong::REQUIRED_ARGUMENT,"Generate First/Follow rules, argument is start symbol"],
|
51
27
|
["--format", "-f", GetoptLong::REQUIRED_ARGUMENT,"Specify output format one of ebnf, html, ttl, sxp, or rb"],
|
52
28
|
["--input-format", GetoptLong::REQUIRED_ARGUMENT,"Specify input format one of ebnf or sxp"],
|
53
29
|
["--mod-name", GetoptLong::REQUIRED_ARGUMENT,"Module name used when creating ruby tables"],
|
54
30
|
["--output", "-o", GetoptLong::REQUIRED_ARGUMENT,"Output to the specified file path"],
|
55
31
|
["--prefix", "-p", GetoptLong::REQUIRED_ARGUMENT,"Prefix to use when generating Turtle"],
|
56
|
-
["--progress", "-v", GetoptLong::NO_ARGUMENT,
|
32
|
+
["--progress", "-v", GetoptLong::NO_ARGUMENT, "Detail on execution"],
|
57
33
|
["--namespace", "-n", GetoptLong::REQUIRED_ARGUMENT,"Namespace to use when generating Turtle"],
|
58
34
|
["--help", "-?", GetoptLong::NO_ARGUMENT, "This message"]
|
59
35
|
]
|
@@ -108,7 +84,7 @@ when :ebnf then ebnf.to_s
|
|
108
84
|
when :html then ebnf.to_html
|
109
85
|
when :sxp then ebnf.to_sxp
|
110
86
|
when :ttl then ebnf.to_ttl(options[:prefix], options[:namespace])
|
111
|
-
when :rb then
|
87
|
+
when :rb then ebnf.to_ruby(out, options.merge(grammarFile: ARGV[0]))
|
112
88
|
else ebnf.ast.inspect
|
113
89
|
end
|
114
90
|
|
data/etc/turtle.rb
CHANGED
data/lib/ebnf/base.rb
CHANGED
@@ -190,6 +190,35 @@ module EBNF
|
|
190
190
|
Writer.html(*ast)
|
191
191
|
end
|
192
192
|
|
193
|
+
##
|
194
|
+
# Output Ruby parser files
|
195
|
+
#
|
196
|
+
# @param [IO, StringIO] output
|
197
|
+
# @param [Hash{Symbol => Object}] options
|
198
|
+
# @option options [String] :grammarFile
|
199
|
+
def to_ruby(output = STDOUT, options = {})
|
200
|
+
self.build_tables
|
201
|
+
unless output == STDOUT
|
202
|
+
output.puts "# This file is automatically generated by #{__FILE__}"
|
203
|
+
output.puts "# BRANCH derived from #{options[:grammarFile]}" if options[:grammarFile]
|
204
|
+
unless self.errors.empty?
|
205
|
+
output.puts "# Note, tables completed with errors, may need to be resolved manually:"
|
206
|
+
#output.puts "# #{pp.conflicts.map{|c| c.join("\n# ")}.join("\n# ")}"
|
207
|
+
end
|
208
|
+
output.puts "module #{options.fetch(:mod_name, 'Branch')}"
|
209
|
+
output.puts " START = #{self.start.inspect}"
|
210
|
+
output.puts
|
211
|
+
end
|
212
|
+
self.outputTable(output, 'BRANCH', self.branch, 1)
|
213
|
+
self.outputTable(output, 'TERMINALS', self.terminals, 1)
|
214
|
+
self.outputTable(output, 'FIRST', self.first, 1)
|
215
|
+
self.outputTable(output, 'FOLLOW', self.follow, 1)
|
216
|
+
self.outputTable(output, 'PASS', [self.pass], 1) if self.pass
|
217
|
+
unless output == STDOUT
|
218
|
+
output.puts "end"
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
193
222
|
def dup
|
194
223
|
new_obj = super
|
195
224
|
new_obj.instance_variable_set(:@ast, @ast.dup)
|
data/lib/ebnf/ll1/lexer.rb
CHANGED
@@ -263,7 +263,9 @@ module EBNF::LL1
|
|
263
263
|
#STDERR.puts "match[#{term.type}] #{scanner.rest[0..100].inspect} against #{term.regexp.inspect}" #if term.type == :STRING_LITERAL_SINGLE_QUOTE
|
264
264
|
if matched = scanner.scan(term.regexp)
|
265
265
|
#STDERR.puts " matched #{term.type.inspect}: #{matched.inspect}"
|
266
|
-
|
266
|
+
tok = token(term.type, term.canonicalize(matched))
|
267
|
+
@lineno += matched.count("\n")
|
268
|
+
return tok
|
267
269
|
end
|
268
270
|
end
|
269
271
|
nil
|
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: 0.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregg Kellogg
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sxp
|
@@ -64,14 +64,28 @@ dependencies:
|
|
64
64
|
requirements:
|
65
65
|
- - "~>"
|
66
66
|
- !ruby/object:Gem::Version
|
67
|
-
version: '
|
67
|
+
version: '3.0'
|
68
68
|
type: :development
|
69
69
|
prerelease: false
|
70
70
|
version_requirements: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - "~>"
|
73
73
|
- !ruby/object:Gem::Version
|
74
|
-
version: '
|
74
|
+
version: '3.0'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rspec-its
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - "~>"
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '1.0'
|
82
|
+
type: :development
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - "~>"
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '1.0'
|
75
89
|
- !ruby/object:Gem::Dependency
|
76
90
|
name: yard
|
77
91
|
requirement: !ruby/object:Gem::Requirement
|
@@ -90,16 +104,16 @@ dependencies:
|
|
90
104
|
name: rake
|
91
105
|
requirement: !ruby/object:Gem::Requirement
|
92
106
|
requirements:
|
93
|
-
- - "
|
107
|
+
- - "~>"
|
94
108
|
- !ruby/object:Gem::Version
|
95
|
-
version: '
|
109
|
+
version: '10.4'
|
96
110
|
type: :development
|
97
111
|
prerelease: false
|
98
112
|
version_requirements: !ruby/object:Gem::Requirement
|
99
113
|
requirements:
|
100
|
-
- - "
|
114
|
+
- - "~>"
|
101
115
|
- !ruby/object:Gem::Version
|
102
|
-
version: '
|
116
|
+
version: '10.4'
|
103
117
|
description: EBNF is a Ruby parser for W3C EBNF and a parser generator for compliant
|
104
118
|
LL(1) grammars.
|
105
119
|
email: public-rdf-ruby@w3.org
|
@@ -147,7 +161,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
147
161
|
requirements:
|
148
162
|
- - ">="
|
149
163
|
- !ruby/object:Gem::Version
|
150
|
-
version: 1.9.
|
164
|
+
version: 1.9.3
|
151
165
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
152
166
|
requirements:
|
153
167
|
- - ">="
|
@@ -155,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
169
|
version: '0'
|
156
170
|
requirements: []
|
157
171
|
rubyforge_project:
|
158
|
-
rubygems_version: 2.
|
172
|
+
rubygems_version: 2.4.5
|
159
173
|
signing_key:
|
160
174
|
specification_version: 4
|
161
175
|
summary: EBNF parser and parser generator.
|