edn-abnf 0.0.10 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/edn-abnf.gemspec +1 -1
- data/lib/cbor-diagnostic-app/dt.rb +25 -0
- data/lib/cbor-diagnostic-app/dtgrammar.rb +700 -0
- data/lib/cbor-diagnostic-app/ip.rb +22 -0
- data/lib/cbor-diagnostic-app/ipgrammar.rb +1698 -0
- data/lib/parser/edn-util.rb +1 -0
- data/lib/parser/edngrammar.rb +296 -30
- metadata +6 -2
data/lib/parser/edn-util.rb
CHANGED
data/lib/parser/edngrammar.rb
CHANGED
@@ -289,13 +289,13 @@ module EDNGRAMMAR
|
|
289
289
|
r0
|
290
290
|
end
|
291
291
|
|
292
|
-
module
|
292
|
+
module String10
|
293
293
|
def spec
|
294
294
|
elements[1]
|
295
295
|
end
|
296
296
|
end
|
297
297
|
|
298
|
-
module
|
298
|
+
module String11
|
299
299
|
def ast
|
300
300
|
if ei = spec.text_value[1..-1]
|
301
301
|
warn "*** ignoring unimplemented encoding indicator #{ei.inspect} for #{elements[0].text_value}"
|
@@ -304,12 +304,12 @@ module EDNGRAMMAR
|
|
304
304
|
end
|
305
305
|
end
|
306
306
|
|
307
|
-
def
|
307
|
+
def _nt_string1
|
308
308
|
start_index = index
|
309
|
-
if node_cache[:
|
310
|
-
cached = node_cache[:
|
309
|
+
if node_cache[:string1].has_key?(index)
|
310
|
+
cached = node_cache[:string1][index]
|
311
311
|
if cached
|
312
|
-
node_cache[:
|
312
|
+
node_cache[:string1][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
313
313
|
@index = cached.interval.end
|
314
314
|
end
|
315
315
|
return cached
|
@@ -338,8 +338,180 @@ module EDNGRAMMAR
|
|
338
338
|
end
|
339
339
|
if s0.last
|
340
340
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
341
|
-
r0.extend(
|
341
|
+
r0.extend(String10)
|
342
|
+
r0.extend(String11)
|
343
|
+
else
|
344
|
+
@index = i0
|
345
|
+
r0 = nil
|
346
|
+
end
|
347
|
+
|
348
|
+
node_cache[:string1][start_index] = r0
|
349
|
+
|
350
|
+
r0
|
351
|
+
end
|
352
|
+
|
353
|
+
def _nt_string1e
|
354
|
+
start_index = index
|
355
|
+
if node_cache[:string1e].has_key?(index)
|
356
|
+
cached = node_cache[:string1e][index]
|
357
|
+
if cached
|
358
|
+
node_cache[:string1e][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
359
|
+
@index = cached.interval.end
|
360
|
+
end
|
361
|
+
return cached
|
362
|
+
end
|
363
|
+
|
364
|
+
i0 = index
|
365
|
+
r1 = _nt_string1
|
366
|
+
if r1
|
367
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
368
|
+
r0 = r1
|
369
|
+
else
|
370
|
+
r2 = _nt_ellipsis
|
371
|
+
if r2
|
372
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
373
|
+
r0 = r2
|
374
|
+
else
|
375
|
+
@index = i0
|
376
|
+
r0 = nil
|
377
|
+
end
|
378
|
+
end
|
379
|
+
|
380
|
+
node_cache[:string1e][start_index] = r0
|
381
|
+
|
382
|
+
r0
|
383
|
+
end
|
384
|
+
|
385
|
+
module Ellipsis0
|
386
|
+
def ast; CBOR::Tagged.new(888, nil) end
|
387
|
+
end
|
388
|
+
|
389
|
+
def _nt_ellipsis
|
390
|
+
start_index = index
|
391
|
+
if node_cache[:ellipsis].has_key?(index)
|
392
|
+
cached = node_cache[:ellipsis][index]
|
393
|
+
if cached
|
394
|
+
node_cache[:ellipsis][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
395
|
+
@index = cached.interval.end
|
396
|
+
end
|
397
|
+
return cached
|
398
|
+
end
|
399
|
+
|
400
|
+
s0, i0 = [], index
|
401
|
+
loop do
|
402
|
+
if (match_len = has_terminal?(".", false, index))
|
403
|
+
r1 = true
|
404
|
+
@index += match_len
|
405
|
+
else
|
406
|
+
terminal_parse_failure('"."')
|
407
|
+
r1 = nil
|
408
|
+
end
|
409
|
+
if r1
|
410
|
+
s0 << r1
|
411
|
+
else
|
412
|
+
break
|
413
|
+
end
|
414
|
+
end
|
415
|
+
if s0.size < 3
|
416
|
+
@index = i0
|
417
|
+
r0 = nil
|
418
|
+
else
|
419
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
420
|
+
r0.extend(Ellipsis0)
|
421
|
+
r0.extend(Ellipsis0)
|
422
|
+
end
|
423
|
+
|
424
|
+
node_cache[:ellipsis][start_index] = r0
|
425
|
+
|
426
|
+
r0
|
427
|
+
end
|
428
|
+
|
429
|
+
module String0
|
430
|
+
def S
|
431
|
+
elements[0]
|
432
|
+
end
|
433
|
+
|
434
|
+
def string1e
|
435
|
+
elements[1]
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
module String1
|
440
|
+
def string1e
|
441
|
+
elements[0]
|
442
|
+
end
|
443
|
+
|
444
|
+
end
|
445
|
+
|
446
|
+
module String2
|
447
|
+
def join1(s)
|
448
|
+
s.join # XXX -- look at encoding and ei
|
449
|
+
end
|
450
|
+
def unpack_chunk(c, s)
|
451
|
+
if c == String
|
452
|
+
join1(s)
|
453
|
+
else
|
454
|
+
unless c == CBOR::Tagged && s.first.tag == 888 && s.first.value == nil # XXX check all values?
|
455
|
+
raise "*** unjoinable chunks #{c.inspect} #{s.inspect}" if s.size != 1
|
456
|
+
end
|
457
|
+
s.first
|
458
|
+
end
|
459
|
+
end
|
460
|
+
def ast
|
461
|
+
arr = [elements[0].ast] + elements[1].elements.map {|x| x.elements[1].ast}
|
462
|
+
charr = arr.chunk(&:class).to_a
|
463
|
+
if charr.size == 1
|
464
|
+
unpack_chunk(*charr.first)
|
465
|
+
else
|
466
|
+
CBOR::Tagged.new(888, charr.map {|x| unpack_chunk(*x)})
|
467
|
+
end
|
468
|
+
end
|
469
|
+
end
|
470
|
+
|
471
|
+
def _nt_string
|
472
|
+
start_index = index
|
473
|
+
if node_cache[:string].has_key?(index)
|
474
|
+
cached = node_cache[:string][index]
|
475
|
+
if cached
|
476
|
+
node_cache[:string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
477
|
+
@index = cached.interval.end
|
478
|
+
end
|
479
|
+
return cached
|
480
|
+
end
|
481
|
+
|
482
|
+
i0, s0 = index, []
|
483
|
+
r1 = _nt_string1e
|
484
|
+
s0 << r1
|
485
|
+
if r1
|
486
|
+
s2, i2 = [], index
|
487
|
+
loop do
|
488
|
+
i3, s3 = index, []
|
489
|
+
r4 = _nt_S
|
490
|
+
s3 << r4
|
491
|
+
if r4
|
492
|
+
r5 = _nt_string1e
|
493
|
+
s3 << r5
|
494
|
+
end
|
495
|
+
if s3.last
|
496
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
497
|
+
r3.extend(String0)
|
498
|
+
else
|
499
|
+
@index = i3
|
500
|
+
r3 = nil
|
501
|
+
end
|
502
|
+
if r3
|
503
|
+
s2 << r3
|
504
|
+
else
|
505
|
+
break
|
506
|
+
end
|
507
|
+
end
|
508
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
509
|
+
s0 << r2
|
510
|
+
end
|
511
|
+
if s0.last
|
512
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
342
513
|
r0.extend(String1)
|
514
|
+
r0.extend(String2)
|
343
515
|
else
|
344
516
|
@index = i0
|
345
517
|
r0 = nil
|
@@ -1228,6 +1400,13 @@ module EDNGRAMMAR
|
|
1228
1400
|
|
1229
1401
|
end
|
1230
1402
|
|
1403
|
+
module AppPrefix1
|
1404
|
+
def ucalpha
|
1405
|
+
elements[0]
|
1406
|
+
end
|
1407
|
+
|
1408
|
+
end
|
1409
|
+
|
1231
1410
|
def _nt_app_prefix
|
1232
1411
|
start_index = index
|
1233
1412
|
if node_cache[:app_prefix].has_key?(index)
|
@@ -1239,28 +1418,64 @@ module EDNGRAMMAR
|
|
1239
1418
|
return cached
|
1240
1419
|
end
|
1241
1420
|
|
1242
|
-
i0
|
1243
|
-
|
1244
|
-
|
1245
|
-
|
1246
|
-
|
1421
|
+
i0 = index
|
1422
|
+
i1, s1 = index, []
|
1423
|
+
r2 = _nt_lcalpha
|
1424
|
+
s1 << r2
|
1425
|
+
if r2
|
1426
|
+
s3, i3 = [], index
|
1247
1427
|
loop do
|
1248
|
-
|
1249
|
-
if
|
1250
|
-
|
1428
|
+
r4 = _nt_lcalnum
|
1429
|
+
if r4
|
1430
|
+
s3 << r4
|
1251
1431
|
else
|
1252
1432
|
break
|
1253
1433
|
end
|
1254
1434
|
end
|
1255
|
-
|
1256
|
-
|
1435
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1436
|
+
s1 << r3
|
1257
1437
|
end
|
1258
|
-
if
|
1259
|
-
|
1260
|
-
|
1438
|
+
if s1.last
|
1439
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1440
|
+
r1.extend(AppPrefix0)
|
1261
1441
|
else
|
1262
|
-
@index =
|
1263
|
-
|
1442
|
+
@index = i1
|
1443
|
+
r1 = nil
|
1444
|
+
end
|
1445
|
+
if r1
|
1446
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
1447
|
+
r0 = r1
|
1448
|
+
else
|
1449
|
+
i5, s5 = index, []
|
1450
|
+
r6 = _nt_ucalpha
|
1451
|
+
s5 << r6
|
1452
|
+
if r6
|
1453
|
+
s7, i7 = [], index
|
1454
|
+
loop do
|
1455
|
+
r8 = _nt_ucalnum
|
1456
|
+
if r8
|
1457
|
+
s7 << r8
|
1458
|
+
else
|
1459
|
+
break
|
1460
|
+
end
|
1461
|
+
end
|
1462
|
+
r7 = instantiate_node(SyntaxNode,input, i7...index, s7)
|
1463
|
+
s5 << r7
|
1464
|
+
end
|
1465
|
+
if s5.last
|
1466
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
1467
|
+
r5.extend(AppPrefix1)
|
1468
|
+
else
|
1469
|
+
@index = i5
|
1470
|
+
r5 = nil
|
1471
|
+
end
|
1472
|
+
if r5
|
1473
|
+
r5 = SyntaxNode.new(input, (index-1)...index) if r5 == true
|
1474
|
+
r0 = r5
|
1475
|
+
else
|
1476
|
+
@index = i0
|
1477
|
+
r0 = nil
|
1478
|
+
end
|
1264
1479
|
end
|
1265
1480
|
|
1266
1481
|
node_cache[:app_prefix][start_index] = r0
|
@@ -1284,7 +1499,8 @@ module EDNGRAMMAR
|
|
1284
1499
|
app = app_prefix.text_value
|
1285
1500
|
# Find a better place to put a default initialization
|
1286
1501
|
EDNGRAMMAR.const_set(:APPS, Hash.new { |h, k|
|
1287
|
-
h[k] = begin ::CBOR_DIAG.const_get("App_#{app}")
|
1502
|
+
h[k] = begin ::CBOR_DIAG.const_get("App_#{app.downcase}")
|
1503
|
+
|
1288
1504
|
rescue NameError
|
1289
1505
|
raise ArgumentError, "cbor-diagnostic: Unknown application-oriented extension '#{k}'", caller
|
1290
1506
|
end
|
@@ -3924,6 +4140,62 @@ module EDNGRAMMAR
|
|
3924
4140
|
r0
|
3925
4141
|
end
|
3926
4142
|
|
4143
|
+
def _nt_ucalpha
|
4144
|
+
start_index = index
|
4145
|
+
if node_cache[:ucalpha].has_key?(index)
|
4146
|
+
cached = node_cache[:ucalpha][index]
|
4147
|
+
if cached
|
4148
|
+
node_cache[:ucalpha][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
4149
|
+
@index = cached.interval.end
|
4150
|
+
end
|
4151
|
+
return cached
|
4152
|
+
end
|
4153
|
+
|
4154
|
+
if has_terminal?(@regexps[gr = '\A[A-Z]'] ||= Regexp.new(gr), :regexp, index)
|
4155
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + 1))
|
4156
|
+
@index += 1
|
4157
|
+
else
|
4158
|
+
terminal_parse_failure('[A-Z]')
|
4159
|
+
r0 = nil
|
4160
|
+
end
|
4161
|
+
|
4162
|
+
node_cache[:ucalpha][start_index] = r0
|
4163
|
+
|
4164
|
+
r0
|
4165
|
+
end
|
4166
|
+
|
4167
|
+
def _nt_ucalnum
|
4168
|
+
start_index = index
|
4169
|
+
if node_cache[:ucalnum].has_key?(index)
|
4170
|
+
cached = node_cache[:ucalnum][index]
|
4171
|
+
if cached
|
4172
|
+
node_cache[:ucalnum][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
4173
|
+
@index = cached.interval.end
|
4174
|
+
end
|
4175
|
+
return cached
|
4176
|
+
end
|
4177
|
+
|
4178
|
+
i0 = index
|
4179
|
+
r1 = _nt_ucalpha
|
4180
|
+
if r1
|
4181
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
4182
|
+
r0 = r1
|
4183
|
+
else
|
4184
|
+
r2 = _nt_DIGIT
|
4185
|
+
if r2
|
4186
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
4187
|
+
r0 = r2
|
4188
|
+
else
|
4189
|
+
@index = i0
|
4190
|
+
r0 = nil
|
4191
|
+
end
|
4192
|
+
end
|
4193
|
+
|
4194
|
+
node_cache[:ucalnum][start_index] = r0
|
4195
|
+
|
4196
|
+
r0
|
4197
|
+
end
|
4198
|
+
|
3927
4199
|
def _nt_wordchar
|
3928
4200
|
start_index = index
|
3929
4201
|
if node_cache[:wordchar].has_key?(index)
|
@@ -3952,13 +4224,7 @@ module EDNGRAMMAR
|
|
3952
4224
|
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
3953
4225
|
r0 = r2
|
3954
4226
|
else
|
3955
|
-
|
3956
|
-
r3 = true
|
3957
|
-
@index += 1
|
3958
|
-
else
|
3959
|
-
terminal_parse_failure('[A-Z]')
|
3960
|
-
r3 = nil
|
3961
|
-
end
|
4227
|
+
r3 = _nt_ucalpha
|
3962
4228
|
if r3
|
3963
4229
|
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
3964
4230
|
r0 = r3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn-abnf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-10-
|
11
|
+
date: 2023-10-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -94,8 +94,12 @@ files:
|
|
94
94
|
- edn-abnf.gemspec
|
95
95
|
- lib/cbor-diagnostic-app/b64.rb
|
96
96
|
- lib/cbor-diagnostic-app/b64grammar.rb
|
97
|
+
- lib/cbor-diagnostic-app/dt.rb
|
98
|
+
- lib/cbor-diagnostic-app/dtgrammar.rb
|
97
99
|
- lib/cbor-diagnostic-app/h.rb
|
98
100
|
- lib/cbor-diagnostic-app/hgrammar.rb
|
101
|
+
- lib/cbor-diagnostic-app/ip.rb
|
102
|
+
- lib/cbor-diagnostic-app/ipgrammar.rb
|
99
103
|
- lib/edn-abnf.rb
|
100
104
|
- lib/parser/edn-util.rb
|
101
105
|
- lib/parser/edngrammar.rb
|