abnftt 0.2.1 → 0.2.3
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 +17 -10
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 570c4b52d32529e01e86cd980a4d4b37f2c8ee3d569e57975969ce0386c84f60
|
4
|
+
data.tar.gz: af8040ce889b4ba98ac0c08cc6a5325d8d19ccca70bbd2669c7d75607963ab1d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d373e24d098491ad7effef16260512c6f0983cdf30d9a0e9f4ba92577f346d789579ff4f820686c4f39b5d7f49ee8daebea4164ef05b11c01f211a71d6bf656
|
7
|
+
data.tar.gz: 86f1c1c0d4333922b2e865f19975da937ff50064e3dbda666e8340b61f788d3fda137005c7f5ab7be3b09418754b40b32d7865d80b245787baa15a076a8fca06
|
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,21 +129,21 @@ 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
|
137
143
|
FIXUP_NAMES = Hash.new {|h, k| k}
|
138
144
|
FIXUP_NAMES.merge!({
|
139
145
|
"rule" => "r__rule",
|
146
|
+
"end" => "r__end",
|
140
147
|
})
|
141
148
|
def to_treetop1(ast)
|
142
149
|
case ast
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-13 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
|
@@ -42,7 +42,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
42
42
|
- !ruby/object:Gem::Version
|
43
43
|
version: '0'
|
44
44
|
requirements: []
|
45
|
-
rubygems_version: 3.2
|
45
|
+
rubygems_version: 3.4.2
|
46
46
|
signing_key:
|
47
47
|
specification_version: 4
|
48
48
|
summary: RFC 5234+7405 ABNF to Treetop
|