abnftt 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/abnftt.gemspec +1 -1
- data/lib/abnfgrammar.rb +6 -6
- data/lib/abnftt.rb +16 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6def221a1f39479205c5ae0941b016e8e9b264cbd22f3052d6d62efba94ec05
|
4
|
+
data.tar.gz: 9ff420d1bb6fae9272704bea9a77141d02cf70638831aa883a88bb4cdbbcf27b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b29184a28e14f98168290f3638c371d92448deff1fbd686d6016eee875c7b5943ac8b9a6aabfb16f23d482f2ec7ca7b1fa0210e754410ab8b26bf4937be9175d
|
7
|
+
data.tar.gz: 011fcd33ac63105e3a4f9ea247841611be6bf9b60430786fab5ad2a9f63c6988ca67b84aca0016428107874bd486989653710b1014384f4877dd9adc34ebeda5
|
data/abnftt.gemspec
CHANGED
data/lib/abnfgrammar.rb
CHANGED
@@ -283,22 +283,22 @@ module ABNFGrammar
|
|
283
283
|
s0 << r1
|
284
284
|
if r1
|
285
285
|
i3 = index
|
286
|
-
if (match_len = has_terminal?("
|
287
|
-
r4 =
|
286
|
+
if (match_len = has_terminal?("=/", false, index))
|
287
|
+
r4 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
288
288
|
@index += match_len
|
289
289
|
else
|
290
|
-
terminal_parse_failure('"
|
290
|
+
terminal_parse_failure('"=/"')
|
291
291
|
r4 = nil
|
292
292
|
end
|
293
293
|
if r4
|
294
294
|
r4 = SyntaxNode.new(input, (index-1)...index) if r4 == true
|
295
295
|
r3 = r4
|
296
296
|
else
|
297
|
-
if (match_len = has_terminal?("
|
298
|
-
r5 =
|
297
|
+
if (match_len = has_terminal?("=", false, index))
|
298
|
+
r5 = true
|
299
299
|
@index += match_len
|
300
300
|
else
|
301
|
-
terminal_parse_failure('"
|
301
|
+
terminal_parse_failure('"="')
|
302
302
|
r5 = nil
|
303
303
|
end
|
304
304
|
if r5
|
data/lib/abnftt.rb
CHANGED
@@ -61,12 +61,19 @@ class ABNF
|
|
61
61
|
@tree.each do |x|
|
62
62
|
op, name, val, rest = x
|
63
63
|
fail rest if rest
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
64
|
+
@rules[name] =
|
65
|
+
if old = @rules[name]
|
66
|
+
fail "duplicate rule for name #{name}" if op == "="
|
67
|
+
if Array === old && old[0] == "alt"
|
68
|
+
old.dup << val
|
69
|
+
else
|
70
|
+
["alt", old, val]
|
71
|
+
end
|
72
|
+
else
|
73
|
+
val
|
74
|
+
end
|
69
75
|
end
|
76
|
+
# warn "** rules #{rules.inspect}"
|
70
77
|
end
|
71
78
|
|
72
79
|
def generate
|
@@ -122,15 +129,14 @@ class ABNF
|
|
122
129
|
<<~EOS
|
123
130
|
# Encoding: UTF-8
|
124
131
|
grammar #{modname}
|
125
|
-
#{
|
132
|
+
#{rules.map {|k, v| to_treetop0(k, v)}.join}
|
126
133
|
end
|
127
134
|
EOS
|
128
135
|
end
|
129
|
-
def to_treetop0(
|
130
|
-
fail ast.inspect unless ast[0] == "="
|
136
|
+
def to_treetop0(k, v)
|
131
137
|
<<~EOS
|
132
|
-
rule #{to_treetop1(
|
133
|
-
#{to_treetop1(
|
138
|
+
rule #{to_treetop1(k)}
|
139
|
+
#{to_treetop1(v)}
|
134
140
|
end
|
135
141
|
EOS
|
136
142
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abnftt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-02-
|
11
|
+
date: 2021-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Less shifty support for tools based on IETF's ABNF
|
14
14
|
email: cabo@tzi.org
|