ebnf 1.1.2 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +218 -196
- data/UNLICENSE +1 -1
- data/VERSION +1 -1
- data/bin/ebnf +40 -21
- data/etc/abnf-core.ebnf +52 -0
- data/etc/abnf.abnf +121 -0
- data/etc/abnf.ebnf +124 -0
- data/etc/abnf.sxp +45 -0
- data/etc/doap.ttl +23 -15
- data/etc/ebnf.ebnf +21 -33
- data/etc/ebnf.html +171 -160
- data/etc/{ebnf.rb → ebnf.ll1.rb} +30 -107
- data/etc/ebnf.ll1.sxp +182 -183
- data/etc/ebnf.peg.rb +90 -0
- data/etc/ebnf.peg.sxp +84 -0
- data/etc/ebnf.sxp +40 -41
- data/etc/iso-ebnf.ebnf +140 -0
- data/etc/iso-ebnf.isoebnf +138 -0
- data/etc/iso-ebnf.sxp +65 -0
- data/etc/sparql.ebnf +4 -4
- data/etc/sparql.html +1603 -1751
- data/etc/sparql.ll1.sxp +7372 -7372
- data/etc/sparql.peg.rb +532 -0
- data/etc/sparql.peg.sxp +597 -0
- data/etc/sparql.sxp +363 -362
- data/etc/turtle.ebnf +3 -3
- data/etc/turtle.html +465 -517
- data/etc/{turtle.rb → turtle.ll1.rb} +3 -4
- data/etc/turtle.ll1.sxp +425 -425
- data/etc/turtle.peg.rb +182 -0
- data/etc/turtle.peg.sxp +199 -0
- data/etc/turtle.sxp +103 -101
- data/lib/ebnf.rb +7 -2
- data/lib/ebnf/abnf.rb +301 -0
- data/lib/ebnf/abnf/core.rb +23 -0
- data/lib/ebnf/abnf/meta.rb +111 -0
- data/lib/ebnf/base.rb +128 -87
- data/lib/ebnf/bnf.rb +1 -26
- data/lib/ebnf/ebnf/meta.rb +90 -0
- data/lib/ebnf/isoebnf.rb +229 -0
- data/lib/ebnf/isoebnf/meta.rb +75 -0
- data/lib/ebnf/ll1.rb +140 -8
- data/lib/ebnf/ll1/lexer.rb +37 -32
- data/lib/ebnf/ll1/parser.rb +113 -73
- data/lib/ebnf/ll1/scanner.rb +83 -51
- data/lib/ebnf/native.rb +320 -0
- data/lib/ebnf/parser.rb +285 -302
- data/lib/ebnf/peg.rb +39 -0
- data/lib/ebnf/peg/parser.rb +561 -0
- data/lib/ebnf/peg/rule.rb +241 -0
- data/lib/ebnf/rule.rb +453 -163
- data/lib/ebnf/terminals.rb +21 -0
- data/lib/ebnf/writer.rb +561 -88
- metadata +114 -28
- data/etc/sparql.rb +0 -45773
data/lib/ebnf.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
module EBNF
|
2
|
+
autoload :ABNF, "ebnf/abnf"
|
2
3
|
autoload :Base, "ebnf/base"
|
3
4
|
autoload :BNF, "ebnf/bnf"
|
5
|
+
autoload :ISOEBNF, "ebnf/isoebnf"
|
4
6
|
autoload :LL1, "ebnf/ll1"
|
7
|
+
autoload :Native, "ebnf/native"
|
5
8
|
autoload :Parser, "ebnf/parser"
|
9
|
+
autoload :PEG, "ebnf/peg"
|
6
10
|
autoload :Rule, "ebnf/rule"
|
11
|
+
autoload :Terminals,"ebnf/terminals"
|
7
12
|
autoload :Writer, "ebnf/writer"
|
8
13
|
autoload :VERSION, "ebnf/version"
|
9
14
|
|
@@ -17,7 +22,7 @@ module EBNF
|
|
17
22
|
# @param [Hash{Symbol => Object}] options
|
18
23
|
# @return [EBNF::Base]
|
19
24
|
# @raise [Exception] on invalid input
|
20
|
-
def self.parse(input, options
|
21
|
-
|
25
|
+
def self.parse(input, **options)
|
26
|
+
::EBNF::Base.new(input, **options)
|
22
27
|
end
|
23
28
|
end
|
data/lib/ebnf/abnf.rb
ADDED
@@ -0,0 +1,301 @@
|
|
1
|
+
require_relative 'abnf/core'
|
2
|
+
require_relative 'abnf/meta'
|
3
|
+
require 'logger'
|
4
|
+
|
5
|
+
# ABNF parser
|
6
|
+
# Parses ABNF into an array of {EBNF::Rule}.
|
7
|
+
module EBNF
|
8
|
+
class ABNF
|
9
|
+
include EBNF::PEG::Parser
|
10
|
+
|
11
|
+
# Regular expressions for both "Core" and ABNF-specific terminals.
|
12
|
+
ALPHA = %r{[\x41-\x5A\x61-\x7A]}
|
13
|
+
VCHAR = %r{[\x20-\x7E]}
|
14
|
+
WSP = %r{[\x20\x09]}
|
15
|
+
CRLF = %r{\x0D?\x0A}
|
16
|
+
COMMENT = %r{;(?:#{WSP}|#{VCHAR})*#{CRLF}}
|
17
|
+
C_NL = %r{#{COMMENT}|#{CRLF}}
|
18
|
+
C_WSP = %r{#{WSP}|(?:#{C_NL}#{WSP})}
|
19
|
+
|
20
|
+
##
|
21
|
+
# Hash of generated {EBNF::Rule} objects by symbol
|
22
|
+
#
|
23
|
+
# @return [Hash{Symbol => EBNF::Rule}]
|
24
|
+
attr_reader :parsed_rules
|
25
|
+
|
26
|
+
##
|
27
|
+
# The following ABNF grammar rules are treated as terminals.
|
28
|
+
|
29
|
+
# `rulename ::= ALPHA (ALPHA | DIGIT | "-")*`
|
30
|
+
terminal(:rulename, /#{ALPHA}(?:#{ALPHA}|[0-9-])*/) do |value|
|
31
|
+
value.to_sym
|
32
|
+
end
|
33
|
+
|
34
|
+
# `defined_as ::= c_wsp* ("=" | "=/") c_wsp*`
|
35
|
+
terminal(:defined_as, /#{C_WSP}*=\/?#{C_WSP}*/) {|value| value.strip}
|
36
|
+
|
37
|
+
# `quoted_string::= DQUOTE [#x20-#x21#x23-#x7E]* DQUOTE`
|
38
|
+
terminal(:quoted_string, /"[\x20-\x21\x23-\x7E]*"/) do |value|
|
39
|
+
value[1..-2]
|
40
|
+
end
|
41
|
+
|
42
|
+
# `bin_val ::= "b" BIT+ (("." BIT+)+ | ("-" BIT+))?`
|
43
|
+
terminal(:bin_val, /b[01]+(?:(?:(?:\.[01]+)+)|(?:-[01]+))?/) do |value|
|
44
|
+
if value.include?('.')
|
45
|
+
# Interpret segments in binary creating a sequence of hex characters or a string
|
46
|
+
hex_or_string(value[1..-1].split('.').map {|b| b.to_i(base=2).chr(Encoding::UTF_8)})
|
47
|
+
elsif value.include?('-')
|
48
|
+
# Interpret as a range
|
49
|
+
[:range, value[1..-1].split('-').map {|b| "#x%x" % b.to_i(base=2)}.join("-")]
|
50
|
+
else
|
51
|
+
# Interpret as a single HEX character
|
52
|
+
[:hex, "#x%x" % value[1..-1].to_i(base=2)]
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# `dec_val ::= "d" DIGIT+ (("." DIGIT+)+ | ("-" DIGIT+))?`
|
57
|
+
terminal(:dec_val, /d[0-9]+(?:(?:(?:\.[0-9]+)+)|(?:-[0-9]+))?/) do |value|
|
58
|
+
if value.include?('.')
|
59
|
+
# Interpret segments in decimal creating a sequence of hex characters or a string
|
60
|
+
hex_or_string(value[1..-1].split('.').map {|b| b.to_i.chr(Encoding::UTF_8)})
|
61
|
+
elsif value.include?('-')
|
62
|
+
# Interpret as a range
|
63
|
+
[:range, value[1..-1].split('-').map {|d| "#x%x" % d.to_i}.join("-")]
|
64
|
+
else
|
65
|
+
# Interpret as a single HEX character
|
66
|
+
[:hex, "#x%x" % value[1..-1].to_i]
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# `hex_val ::= "x" HEXDIG+ (("." HEXDIG+)+ | ("-" HEXDIG+))?`
|
71
|
+
terminal(:hex_val, /x[0-9A-F]+(?:(?:(?:\.[0-9A-F]+)+)|(?:-[0-9A-F]+))?/i) do |value|
|
72
|
+
if value.include?('.')
|
73
|
+
# Interpret segments in hexadecimal creating a sequence of hex characters or a string
|
74
|
+
hex_or_string(value[1..-1].split('.').map {|b| b.to_i(base=16).chr(Encoding::UTF_8)})
|
75
|
+
elsif value.include?('-')
|
76
|
+
# Interpret as a range
|
77
|
+
[:range, value[1..-1].split('-').map {|h| "#x%x" % h.to_i(base=16)}.join("-")]
|
78
|
+
else
|
79
|
+
# Interpret as a single HEX character
|
80
|
+
[:hex, "#x#{value[1..-1]}"]
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
# `c_wsp ::= WSP | (c_nl WSP)`
|
85
|
+
terminal(:c_wsp, C_WSP)
|
86
|
+
|
87
|
+
# `c_nl ::= comment | CRLF`
|
88
|
+
terminal(:c_nl, C_NL)
|
89
|
+
|
90
|
+
# `DIGIT ::= [#x30-#x39]`
|
91
|
+
terminal(:DIGIT, /\d/)
|
92
|
+
|
93
|
+
# ## Non-terminal productions
|
94
|
+
|
95
|
+
# The `start_production` on `:rule` allows the parser to present the value as a single Hash, rather than an array of individual hashes.
|
96
|
+
start_production(:rule, as_hash: true)
|
97
|
+
|
98
|
+
# `rule ::= rulename defined_as elements c_nl`
|
99
|
+
production(:rule) do |value|
|
100
|
+
# value contains an expression.
|
101
|
+
# Invoke callback
|
102
|
+
sym = value[:rulename]
|
103
|
+
elements = value[:elements]
|
104
|
+
|
105
|
+
if value[:defined_as] == "=/"
|
106
|
+
# append to rule alternate
|
107
|
+
rule = parsed_rules.fetch(sym) {raise "No existing rule found for #{sym}"}
|
108
|
+
rule.expr = [:alt, rule.expr] unless rule.alt?
|
109
|
+
if elements.is_a?(Array) && elements.first == :alt
|
110
|
+
# append alternatives to rule
|
111
|
+
rule.expr.concat(elements[1..-1])
|
112
|
+
else
|
113
|
+
# add elements as last alternative
|
114
|
+
rule.expr.push(elements)
|
115
|
+
end
|
116
|
+
else
|
117
|
+
# There shouldn't be an existing rule
|
118
|
+
raise "Redefining rule #{sym}" if parsed_rules.has_key?(sym)
|
119
|
+
parsed_rules[sym] = EBNF::Rule.new(sym.to_sym, nil, elements)
|
120
|
+
end
|
121
|
+
progress(:rule, level: 2) {parsed_rules[sym].to_sxp}
|
122
|
+
sym
|
123
|
+
end
|
124
|
+
|
125
|
+
# `elements ::= alternation c_wsp*`
|
126
|
+
production(:elements) do |value|
|
127
|
+
value.first[:alternation]
|
128
|
+
end
|
129
|
+
|
130
|
+
# `alternation ::= concatenation (c_wsp* "/" c_wsp* concatenation)*`
|
131
|
+
production(:alternation) do |value|
|
132
|
+
unless value.last[:_alternation_1].empty?
|
133
|
+
[:alt, value.first[:concatenation]] + value.last[:_alternation_1]
|
134
|
+
else
|
135
|
+
value.first[:concatenation]
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# The `_aleteration_2` rule comes from the expanded PEG grammar and serves as an opportunity to custommize the values presented to the `aleteration` rule.
|
140
|
+
production(:_alternation_2) do |value|
|
141
|
+
if Array(value.last[:concatenation]).first == :alt
|
142
|
+
value.last[:concatenation][1..-1]
|
143
|
+
else
|
144
|
+
[value.last[:concatenation]]
|
145
|
+
end
|
146
|
+
value.last[:concatenation]
|
147
|
+
end
|
148
|
+
|
149
|
+
# `concatenation::= repetition (c_wsp+ repetition)*`
|
150
|
+
production(:concatenation) do |value|
|
151
|
+
unless value.last[:_concatenation_1].empty?
|
152
|
+
[:seq, value.first[:repetition]] + value.last[:_concatenation_1]
|
153
|
+
else
|
154
|
+
value.first[:repetition]
|
155
|
+
end
|
156
|
+
end
|
157
|
+
start_production(:_concatenation_2, as_hash: true)
|
158
|
+
production(:_concatenation_2) do |value|
|
159
|
+
value[:repetition]
|
160
|
+
end
|
161
|
+
|
162
|
+
# `repetition ::= repeat? element`
|
163
|
+
production(:repetition) do |value|
|
164
|
+
rept = value.first[:_repetition_1]
|
165
|
+
elt = value.last[:element]
|
166
|
+
case rept
|
167
|
+
when [0, '*'] then [:star, elt]
|
168
|
+
when [1, '*'] then [:plus, elt]
|
169
|
+
when nil then elt
|
170
|
+
else
|
171
|
+
[:rept, rept.first, rept.last, elt]
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
# `repeat ::= DIGIT+ | (DIGIT* "*" DIGIT*)`
|
176
|
+
production(:repeat) do |value|
|
177
|
+
if value.is_a?(Integer)
|
178
|
+
[value, value]
|
179
|
+
else
|
180
|
+
[value.first, value.last]
|
181
|
+
end
|
182
|
+
end
|
183
|
+
start_production(:_repeat_1, as_hash: true)
|
184
|
+
production(:_repeat_1) {|value| value.values}
|
185
|
+
production(:_repeat_2) {|value| value.join("").to_i}
|
186
|
+
production(:_repeat_3) {|value| value.join("").to_i}
|
187
|
+
production(:_repeat_4) {|value| value.length > 0 ? value.join("").to_i : '*'}
|
188
|
+
|
189
|
+
# `element ::= rulename | group | option | char_val | num_val | prose_val`
|
190
|
+
production(:element) do |value|
|
191
|
+
value
|
192
|
+
end
|
193
|
+
|
194
|
+
# `group ::= "(" c_wsp* alternation c_wsp* ")"`
|
195
|
+
start_production(:group, as_hash: true)
|
196
|
+
production(:group) do |value|
|
197
|
+
value[:alternation]
|
198
|
+
end
|
199
|
+
|
200
|
+
# `option ::= "[" c_wsp* alternation c_wsp* "]"`
|
201
|
+
start_production(:option, as_hash: true)
|
202
|
+
production(:option) do |value|
|
203
|
+
[:opt, value[:alternation]]
|
204
|
+
end
|
205
|
+
|
206
|
+
# `case_insensitive_string ::= "%i"? quoted_string`
|
207
|
+
production(:case_insensitive_string) do |value|
|
208
|
+
str = value.last[:quoted_string]
|
209
|
+
if str.match?(/[[:alpha:]]/)
|
210
|
+
# Only need to use case-insensitive if there are alphabetic characters in the string.
|
211
|
+
[:istr, value.last[:quoted_string]]
|
212
|
+
else
|
213
|
+
value.last[:quoted_string]
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
# `case_sensitive_string ::= "%s" quoted_string`
|
218
|
+
production(:case_sensitive_string) do |value|
|
219
|
+
value.last[:quoted_string]
|
220
|
+
end
|
221
|
+
|
222
|
+
# `num_val ::= "%" (bin_val | dec_val | hex_val)`
|
223
|
+
production(:num_val) do |value|
|
224
|
+
value.last[:_num_val_1]
|
225
|
+
end
|
226
|
+
|
227
|
+
# ## Parser invocation.
|
228
|
+
# On start, yield ourselves if a block is given, otherwise, return this parser instance
|
229
|
+
#
|
230
|
+
# @param [#read, #to_s] input
|
231
|
+
# @param [Hash{Symbol => Object}] options
|
232
|
+
# @option options [Boolean] :level
|
233
|
+
# Trace level. 0(debug), 1(info), 2(warn), 3(error).
|
234
|
+
# @return [EBNFParser]
|
235
|
+
def initialize(input, **options)
|
236
|
+
# If the `level` option is set, instantiate a logger for collecting trace information.
|
237
|
+
if options.has_key?(:level)
|
238
|
+
options[:logger] = Logger.new(STDERR)
|
239
|
+
options[:logger].level = options[:level]
|
240
|
+
options[:logger].formatter = lambda {|severity, datetime, progname, msg| "#{severity} #{msg}\n"}
|
241
|
+
end
|
242
|
+
|
243
|
+
# Read input, if necessary, which will be used in a Scanner.
|
244
|
+
@input = input.respond_to?(:read) ? input.read : input.to_s
|
245
|
+
|
246
|
+
@parsed_rules = {}
|
247
|
+
|
248
|
+
# Parses into `@parsed_rules`
|
249
|
+
parse(@input,
|
250
|
+
:rulelist, # Starting rule
|
251
|
+
ABNFMeta::RULES, # PEG rules
|
252
|
+
whitespace: '', # No implicit whitespace
|
253
|
+
**options)
|
254
|
+
rescue EBNF::PEG::Parser::Error => e
|
255
|
+
raise SyntaxError, e.message
|
256
|
+
end
|
257
|
+
|
258
|
+
##
|
259
|
+
# The AST includes the parsed rules along with built-in rules for ABNF used within the parsed grammar.
|
260
|
+
#
|
261
|
+
# @return [Array<EBNF::Rule>]
|
262
|
+
def ast
|
263
|
+
# Add built-in rules for standard ABNF rules not
|
264
|
+
parsed_rules.values.map(&:symbols).flatten.uniq.each do |sym|
|
265
|
+
rule = ABNFCore::RULES.detect {|r| r.sym == sym}
|
266
|
+
parsed_rules[sym] ||= rule if rule
|
267
|
+
end
|
268
|
+
|
269
|
+
parsed_rules.values
|
270
|
+
end
|
271
|
+
|
272
|
+
private
|
273
|
+
# Generate a combination of seq and string to represent a sequence of characters
|
274
|
+
#
|
275
|
+
# @param [Array<String>] characters
|
276
|
+
# @return [String,Array]
|
277
|
+
def hex_or_string(characters)
|
278
|
+
seq = [:seq]
|
279
|
+
str_result = ""
|
280
|
+
characters.each do |c|
|
281
|
+
if VCHAR.match?(c)
|
282
|
+
str_result << c
|
283
|
+
else
|
284
|
+
if str_result.length > 0
|
285
|
+
seq << str_result
|
286
|
+
str_result = ""
|
287
|
+
end
|
288
|
+
seq << [:hex, "#x%x" % c.codepoints.first]
|
289
|
+
end
|
290
|
+
end
|
291
|
+
seq << str_result if str_result.length > 0
|
292
|
+
|
293
|
+
# Either return the sequence, or a string
|
294
|
+
if seq.length == 2 && seq.last.is_a?(String)
|
295
|
+
seq.last
|
296
|
+
else
|
297
|
+
seq
|
298
|
+
end
|
299
|
+
end
|
300
|
+
end
|
301
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# This file is automatically generated by ebnf version 2.0.0
|
2
|
+
# Derived from etc/abnf-core.ebnf
|
3
|
+
module ABNFCore
|
4
|
+
RULES = [
|
5
|
+
EBNF::Rule.new(:ALPHA, nil, [:range, "#x41-#x5A#x61-#x7A"], kind: :terminal),
|
6
|
+
EBNF::Rule.new(:BIT, nil, [:alt, "0", "1"], kind: :terminal),
|
7
|
+
EBNF::Rule.new(:CHAR, nil, [:range, "#x01-#x7F"], kind: :terminal),
|
8
|
+
EBNF::Rule.new(:CR, nil, [:hex, "#x0D"], kind: :terminal),
|
9
|
+
EBNF::Rule.new(:CRLF, nil, [:seq, [:opt, :CR], :LF], kind: :terminal),
|
10
|
+
EBNF::Rule.new(:CTL, nil, [:alt, [:range, "#x00-#x1F"], [:hex, "#x7F"]], kind: :terminal),
|
11
|
+
EBNF::Rule.new(:DIGIT, nil, [:range, "#x30-#x39"], kind: :terminal),
|
12
|
+
EBNF::Rule.new(:DQUOTE, nil, [:hex, "#x22"], kind: :terminal),
|
13
|
+
EBNF::Rule.new(:HEXDIG, nil, [:alt, :DIGIT, [:range, "A-F"]], kind: :terminal),
|
14
|
+
EBNF::Rule.new(:HTAB, nil, [:hex, "#x09"], kind: :terminal),
|
15
|
+
EBNF::Rule.new(:LF, nil, [:hex, "#x0A"], kind: :terminal),
|
16
|
+
EBNF::Rule.new(:LWSP, nil, [:star, [:alt, :WSP, [:seq, :CRLF, :WSP]]], kind: :terminal),
|
17
|
+
EBNF::Rule.new(:OCTET, nil, [:range, "#x00-#xFF"], kind: :terminal),
|
18
|
+
EBNF::Rule.new(:SP, nil, [:hex, "#x20"], kind: :terminal),
|
19
|
+
EBNF::Rule.new(:VCHAR, nil, [:range, "#x21-#x7E"], kind: :terminal),
|
20
|
+
EBNF::Rule.new(:WSP, nil, [:alt, :SP, :HTAB], kind: :terminal),
|
21
|
+
]
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,111 @@
|
|
1
|
+
# This file is automatically generated by ebnf version 2.0.0
|
2
|
+
# Derived from abnf.ebnf
|
3
|
+
module ABNFMeta
|
4
|
+
RULES = [
|
5
|
+
EBNF::Rule.new(:rulelist, nil, [:plus, :_rulelist_1]).extend(EBNF::PEG::Rule),
|
6
|
+
EBNF::Rule.new(:_rulelist_1, nil, [:alt, :rule, :_rulelist_2]).extend(EBNF::PEG::Rule),
|
7
|
+
EBNF::Rule.new(:_rulelist_2, nil, [:seq, :_rulelist_3, :c_nl]).extend(EBNF::PEG::Rule),
|
8
|
+
EBNF::Rule.new(:_rulelist_3, nil, [:star, :c_wsp]).extend(EBNF::PEG::Rule),
|
9
|
+
EBNF::Rule.new(:rule, nil, [:seq, :rulename, :defined_as, :elements, :c_nl]).extend(EBNF::PEG::Rule),
|
10
|
+
EBNF::Rule.new(:elements, nil, [:seq, :alternation, :_elements_1]).extend(EBNF::PEG::Rule),
|
11
|
+
EBNF::Rule.new(:_elements_1, nil, [:star, :c_wsp]).extend(EBNF::PEG::Rule),
|
12
|
+
EBNF::Rule.new(:alternation, nil, [:seq, :concatenation, :_alternation_1]).extend(EBNF::PEG::Rule),
|
13
|
+
EBNF::Rule.new(:_alternation_1, nil, [:star, :_alternation_2]).extend(EBNF::PEG::Rule),
|
14
|
+
EBNF::Rule.new(:_alternation_2, nil, [:seq, :_alternation_3, "/", :_alternation_4, :concatenation]).extend(EBNF::PEG::Rule),
|
15
|
+
EBNF::Rule.new(:_alternation_3, nil, [:star, :c_wsp]).extend(EBNF::PEG::Rule),
|
16
|
+
EBNF::Rule.new(:_alternation_4, nil, [:star, :c_wsp]).extend(EBNF::PEG::Rule),
|
17
|
+
EBNF::Rule.new(:concatenation, nil, [:seq, :repetition, :_concatenation_1]).extend(EBNF::PEG::Rule),
|
18
|
+
EBNF::Rule.new(:_concatenation_1, nil, [:star, :_concatenation_2]).extend(EBNF::PEG::Rule),
|
19
|
+
EBNF::Rule.new(:_concatenation_2, nil, [:seq, :_concatenation_3, :repetition]).extend(EBNF::PEG::Rule),
|
20
|
+
EBNF::Rule.new(:_concatenation_3, nil, [:plus, :c_wsp]).extend(EBNF::PEG::Rule),
|
21
|
+
EBNF::Rule.new(:repetition, nil, [:seq, :_repetition_1, :element]).extend(EBNF::PEG::Rule),
|
22
|
+
EBNF::Rule.new(:_repetition_1, nil, [:opt, :repeat]).extend(EBNF::PEG::Rule),
|
23
|
+
EBNF::Rule.new(:repeat, nil, [:alt, :_repeat_1, :_repeat_2]).extend(EBNF::PEG::Rule),
|
24
|
+
EBNF::Rule.new(:_repeat_1, nil, [:seq, :_repeat_3, "*", :_repeat_4]).extend(EBNF::PEG::Rule),
|
25
|
+
EBNF::Rule.new(:_repeat_3, nil, [:star, :DIGIT]).extend(EBNF::PEG::Rule),
|
26
|
+
EBNF::Rule.new(:_repeat_4, nil, [:star, :DIGIT]).extend(EBNF::PEG::Rule),
|
27
|
+
EBNF::Rule.new(:_repeat_2, nil, [:plus, :DIGIT]).extend(EBNF::PEG::Rule),
|
28
|
+
EBNF::Rule.new(:element, nil, [:alt, :rulename, :group, :option, :char_val, :num_val, :prose_val]).extend(EBNF::PEG::Rule),
|
29
|
+
EBNF::Rule.new(:group, nil, [:seq, "(", :_group_1, :alternation, :_group_2, ")"]).extend(EBNF::PEG::Rule),
|
30
|
+
EBNF::Rule.new(:_group_1, nil, [:star, :c_wsp]).extend(EBNF::PEG::Rule),
|
31
|
+
EBNF::Rule.new(:_group_2, nil, [:star, :c_wsp]).extend(EBNF::PEG::Rule),
|
32
|
+
EBNF::Rule.new(:option, nil, [:seq, "[", :_option_1, :alternation, :_option_2, "]"]).extend(EBNF::PEG::Rule),
|
33
|
+
EBNF::Rule.new(:_option_1, nil, [:star, :c_wsp]).extend(EBNF::PEG::Rule),
|
34
|
+
EBNF::Rule.new(:_option_2, nil, [:star, :c_wsp]).extend(EBNF::PEG::Rule),
|
35
|
+
EBNF::Rule.new(:char_val, nil, [:alt, :case_insensitive_string, :case_sensitive_string]).extend(EBNF::PEG::Rule),
|
36
|
+
EBNF::Rule.new(:case_insensitive_string, nil, [:seq, :_case_insensitive_string_1, :quoted_string]).extend(EBNF::PEG::Rule),
|
37
|
+
EBNF::Rule.new(:_case_insensitive_string_1, nil, [:opt, "%i"]).extend(EBNF::PEG::Rule),
|
38
|
+
EBNF::Rule.new(:case_sensitive_string, nil, [:seq, "%s", :quoted_string]).extend(EBNF::PEG::Rule),
|
39
|
+
EBNF::Rule.new(:num_val, nil, [:seq, "%", :_num_val_1]).extend(EBNF::PEG::Rule),
|
40
|
+
EBNF::Rule.new(:_num_val_1, nil, [:alt, :bin_val, :dec_val, :hex_val]).extend(EBNF::PEG::Rule),
|
41
|
+
EBNF::Rule.new(:rulename, nil, [:seq, :ALPHA, :_rulename_1], kind: :terminal).extend(EBNF::PEG::Rule),
|
42
|
+
EBNF::Rule.new(:_rulename_1, nil, [:star, :_rulename_2]).extend(EBNF::PEG::Rule),
|
43
|
+
EBNF::Rule.new(:_rulename_2, nil, [:alt, :ALPHA, :DIGIT, "-"]).extend(EBNF::PEG::Rule),
|
44
|
+
EBNF::Rule.new(:defined_as, nil, [:seq, :_defined_as_1, :_defined_as_2, :_defined_as_3], kind: :terminal).extend(EBNF::PEG::Rule),
|
45
|
+
EBNF::Rule.new(:_defined_as_1, nil, [:star, :c_wsp]).extend(EBNF::PEG::Rule),
|
46
|
+
EBNF::Rule.new(:_defined_as_2, nil, [:alt, "=", "=/"]).extend(EBNF::PEG::Rule),
|
47
|
+
EBNF::Rule.new(:_defined_as_3, nil, [:star, :c_wsp]).extend(EBNF::PEG::Rule),
|
48
|
+
EBNF::Rule.new(:c_wsp, nil, [:alt, :WSP, :_c_wsp_1], kind: :terminal).extend(EBNF::PEG::Rule),
|
49
|
+
EBNF::Rule.new(:_c_wsp_1, nil, [:seq, :c_nl, :WSP]).extend(EBNF::PEG::Rule),
|
50
|
+
EBNF::Rule.new(:c_nl, nil, [:alt, :COMMENT, :CRLF], kind: :terminal).extend(EBNF::PEG::Rule),
|
51
|
+
EBNF::Rule.new(:comment, nil, [:seq, ";", :_comment_1, :CRLF], kind: :terminal).extend(EBNF::PEG::Rule),
|
52
|
+
EBNF::Rule.new(:_comment_1, nil, [:star, :_comment_2]).extend(EBNF::PEG::Rule),
|
53
|
+
EBNF::Rule.new(:_comment_2, nil, [:alt, :WSP, :VCHAR]).extend(EBNF::PEG::Rule),
|
54
|
+
EBNF::Rule.new(:quoted_string, nil, [:seq, :DQUOTE, :_quoted_string_1, :DQUOTE], kind: :terminal).extend(EBNF::PEG::Rule),
|
55
|
+
EBNF::Rule.new(:_quoted_string_1, nil, [:star, :_quoted_string_2]).extend(EBNF::PEG::Rule),
|
56
|
+
EBNF::Rule.new(:_quoted_string_2, nil, [:range, "#x20-#x21#x23-#x7E"], kind: :terminal).extend(EBNF::PEG::Rule),
|
57
|
+
EBNF::Rule.new(:bin_val, nil, [:seq, "b", :_bin_val_1, :_bin_val_2], kind: :terminal).extend(EBNF::PEG::Rule),
|
58
|
+
EBNF::Rule.new(:_bin_val_1, nil, [:plus, :BIT]).extend(EBNF::PEG::Rule),
|
59
|
+
EBNF::Rule.new(:_bin_val_2, nil, [:opt, :_bin_val_3]).extend(EBNF::PEG::Rule),
|
60
|
+
EBNF::Rule.new(:_bin_val_3, nil, [:alt, :_bin_val_4, :_bin_val_5]).extend(EBNF::PEG::Rule),
|
61
|
+
EBNF::Rule.new(:_bin_val_4, nil, [:plus, :_bin_val_6]).extend(EBNF::PEG::Rule),
|
62
|
+
EBNF::Rule.new(:_bin_val_6, nil, [:seq, ".", :_bin_val_7]).extend(EBNF::PEG::Rule),
|
63
|
+
EBNF::Rule.new(:_bin_val_7, nil, [:plus, :BIT]).extend(EBNF::PEG::Rule),
|
64
|
+
EBNF::Rule.new(:_bin_val_5, nil, [:seq, "-", :_bin_val_8]).extend(EBNF::PEG::Rule),
|
65
|
+
EBNF::Rule.new(:_bin_val_8, nil, [:plus, :BIT]).extend(EBNF::PEG::Rule),
|
66
|
+
EBNF::Rule.new(:dec_val, nil, [:seq, "d", :_dec_val_1, :_dec_val_2], kind: :terminal).extend(EBNF::PEG::Rule),
|
67
|
+
EBNF::Rule.new(:_dec_val_1, nil, [:plus, :DIGIT]).extend(EBNF::PEG::Rule),
|
68
|
+
EBNF::Rule.new(:_dec_val_2, nil, [:opt, :_dec_val_3]).extend(EBNF::PEG::Rule),
|
69
|
+
EBNF::Rule.new(:_dec_val_3, nil, [:alt, :_dec_val_4, :_dec_val_5]).extend(EBNF::PEG::Rule),
|
70
|
+
EBNF::Rule.new(:_dec_val_4, nil, [:plus, :_dec_val_6]).extend(EBNF::PEG::Rule),
|
71
|
+
EBNF::Rule.new(:_dec_val_6, nil, [:seq, ".", :_dec_val_7]).extend(EBNF::PEG::Rule),
|
72
|
+
EBNF::Rule.new(:_dec_val_7, nil, [:plus, :DIGIT]).extend(EBNF::PEG::Rule),
|
73
|
+
EBNF::Rule.new(:_dec_val_5, nil, [:seq, "-", :_dec_val_8]).extend(EBNF::PEG::Rule),
|
74
|
+
EBNF::Rule.new(:_dec_val_8, nil, [:plus, :DIGIT]).extend(EBNF::PEG::Rule),
|
75
|
+
EBNF::Rule.new(:hex_val, nil, [:seq, "x", :_hex_val_1, :_hex_val_2], kind: :terminal).extend(EBNF::PEG::Rule),
|
76
|
+
EBNF::Rule.new(:_hex_val_1, nil, [:plus, :HEXDIG]).extend(EBNF::PEG::Rule),
|
77
|
+
EBNF::Rule.new(:_hex_val_2, nil, [:opt, :_hex_val_3]).extend(EBNF::PEG::Rule),
|
78
|
+
EBNF::Rule.new(:_hex_val_3, nil, [:alt, :_hex_val_4, :_hex_val_5]).extend(EBNF::PEG::Rule),
|
79
|
+
EBNF::Rule.new(:_hex_val_4, nil, [:plus, :_hex_val_6]).extend(EBNF::PEG::Rule),
|
80
|
+
EBNF::Rule.new(:_hex_val_6, nil, [:seq, ".", :_hex_val_7]).extend(EBNF::PEG::Rule),
|
81
|
+
EBNF::Rule.new(:_hex_val_7, nil, [:plus, :HEXDIG]).extend(EBNF::PEG::Rule),
|
82
|
+
EBNF::Rule.new(:_hex_val_5, nil, [:seq, "-", :_hex_val_8]).extend(EBNF::PEG::Rule),
|
83
|
+
EBNF::Rule.new(:_hex_val_8, nil, [:plus, :HEXDIG]).extend(EBNF::PEG::Rule),
|
84
|
+
EBNF::Rule.new(:prose_val, nil, [:seq, "<", :_prose_val_1, ">"], kind: :terminal).extend(EBNF::PEG::Rule),
|
85
|
+
EBNF::Rule.new(:_prose_val_1, nil, [:star, :_prose_val_2]).extend(EBNF::PEG::Rule),
|
86
|
+
EBNF::Rule.new(:_prose_val_2, nil, [:range, "#x20-#x3D#x3F-#x7E"], kind: :terminal).extend(EBNF::PEG::Rule),
|
87
|
+
EBNF::Rule.new(:ALPHA, nil, [:range, "#x41-#x5A#x61-#x7A"], kind: :terminal).extend(EBNF::PEG::Rule),
|
88
|
+
EBNF::Rule.new(:BIT, nil, [:alt, "0", "1"], kind: :terminal).extend(EBNF::PEG::Rule),
|
89
|
+
EBNF::Rule.new(:CHAR, nil, [:range, "#x01-#x7F"], kind: :terminal).extend(EBNF::PEG::Rule),
|
90
|
+
EBNF::Rule.new(:CR, nil, [:hex, "#x0D"], kind: :terminal).extend(EBNF::PEG::Rule),
|
91
|
+
EBNF::Rule.new(:CRLF, nil, [:seq, :_CRLF_1, :LF], kind: :terminal).extend(EBNF::PEG::Rule),
|
92
|
+
EBNF::Rule.new(:_CRLF_1, nil, [:opt, :CR], kind: :terminal).extend(EBNF::PEG::Rule),
|
93
|
+
EBNF::Rule.new(:CTL, nil, [:alt, :_CTL_1, :_CTL_2], kind: :terminal).extend(EBNF::PEG::Rule),
|
94
|
+
EBNF::Rule.new(:_CTL_1, nil, [:range, "#x00-#x1F"], kind: :terminal).extend(EBNF::PEG::Rule),
|
95
|
+
EBNF::Rule.new(:_CTL_2, nil, [:hex, "#x7F"], kind: :terminal).extend(EBNF::PEG::Rule),
|
96
|
+
EBNF::Rule.new(:DIGIT, nil, [:range, "#x30-#x39"], kind: :terminal).extend(EBNF::PEG::Rule),
|
97
|
+
EBNF::Rule.new(:DQUOTE, nil, [:hex, "#x22"], kind: :terminal).extend(EBNF::PEG::Rule),
|
98
|
+
EBNF::Rule.new(:HEXDIG, nil, [:alt, :DIGIT, :_HEXDIG_1], kind: :terminal).extend(EBNF::PEG::Rule),
|
99
|
+
EBNF::Rule.new(:_HEXDIG_1, nil, [:range, "A-F"], kind: :terminal).extend(EBNF::PEG::Rule),
|
100
|
+
EBNF::Rule.new(:HTAB, nil, [:hex, "#x09"], kind: :terminal).extend(EBNF::PEG::Rule),
|
101
|
+
EBNF::Rule.new(:LF, nil, [:hex, "#x0A"], kind: :terminal).extend(EBNF::PEG::Rule),
|
102
|
+
EBNF::Rule.new(:LWSP, nil, [:star, :_LWSP_1], kind: :terminal).extend(EBNF::PEG::Rule),
|
103
|
+
EBNF::Rule.new(:_LWSP_1, nil, [:alt, :WSP, :_LWSP_2], kind: :terminal).extend(EBNF::PEG::Rule),
|
104
|
+
EBNF::Rule.new(:_LWSP_2, nil, [:seq, :CRLF, :WSP], kind: :terminal).extend(EBNF::PEG::Rule),
|
105
|
+
EBNF::Rule.new(:OCTET, nil, [:range, "#x00-#xFF"], kind: :terminal).extend(EBNF::PEG::Rule),
|
106
|
+
EBNF::Rule.new(:SP, nil, [:hex, "#x20"], kind: :terminal).extend(EBNF::PEG::Rule),
|
107
|
+
EBNF::Rule.new(:VCHAR, nil, [:range, "#x21-#x7E"], kind: :terminal).extend(EBNF::PEG::Rule),
|
108
|
+
EBNF::Rule.new(:WSP, nil, [:alt, :SP, :HTAB], kind: :terminal).extend(EBNF::PEG::Rule),
|
109
|
+
]
|
110
|
+
end
|
111
|
+
|