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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 397c4ddc806faa5fcb39bc900acb4fb828289c2d639a24ff10158bd0d4712bab
4
- data.tar.gz: d8e1904fc3a2310ba3ab986840cc57bac9bcca1479cda0939ebda3ae19baa36c
3
+ metadata.gz: b6def221a1f39479205c5ae0941b016e8e9b264cbd22f3052d6d62efba94ec05
4
+ data.tar.gz: 9ff420d1bb6fae9272704bea9a77141d02cf70638831aa883a88bb4cdbbcf27b
5
5
  SHA512:
6
- metadata.gz: 280d0eaee9b999e7c9a9b7cac343e1653a6910ecba9e88cb3d8f44652dfd31b440fd2483d8ce4164440a50f15a61e76fa8dbbd4dd98d3cd9004916eb0fb1675a
7
- data.tar.gz: b19f0ebe121e9156c2a3f0cec93fc9e20710e69450981a8f76271bb008f9e432f9b5c9b0605194282cda2ffb39ed6216e427ab6eee5e1a4fec7e5e4799ceef5c
6
+ metadata.gz: b29184a28e14f98168290f3638c371d92448deff1fbd686d6016eee875c7b5943ac8b9a6aabfb16f23d482f2ec7ca7b1fa0210e754410ab8b26bf4937be9175d
7
+ data.tar.gz: 011fcd33ac63105e3a4f9ea247841611be6bf9b60430786fab5ad2a9f63c6988ca67b84aca0016428107874bd486989653710b1014384f4877dd9adc34ebeda5
data/abnftt.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "abnftt"
3
- s.version = "0.2.1"
3
+ s.version = "0.2.2"
4
4
  s.summary = "RFC 5234+7405 ABNF to Treetop"
5
5
  s.description = %q{Less shifty support for tools based on IETF's ABNF}
6
6
  s.author = "Carsten Bormann"
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?("=", false, index))
287
- r4 = true
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?("=/", false, index))
298
- r5 = instantiate_node(SyntaxNode,input, index...(index + match_len))
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
- fail op unless op == "=" # XXX
65
- if @rules[name]
66
- fail "duplicate rule for name #{name}"
67
- end
68
- @rules[name] = val
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
- #{tree.map {|x| to_treetop0(x)}.join}
132
+ #{rules.map {|k, v| to_treetop0(k, v)}.join}
126
133
  end
127
134
  EOS
128
135
  end
129
- def to_treetop0(ast)
130
- fail ast.inspect unless ast[0] == "="
136
+ def to_treetop0(k, v)
131
137
  <<~EOS
132
- rule #{to_treetop1(ast[1])}
133
- #{to_treetop1(ast[2])}
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.1
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-25 00:00:00.000000000 Z
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