edn-abnf 0.0.10 → 0.0.11

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: 932c447340ccec81fa10c0b51f802906872bdbd544473aa6301f98b490ef8aef
4
- data.tar.gz: fa2e2062c8eb6243029011b790e519dd5d24b3fe61960e12cefc4d253d92dd1f
3
+ metadata.gz: 4dd67fd4813a8adf98e4bbffd069e9d9e40a9c8d4c51c9f1ef1226497d3e7e9b
4
+ data.tar.gz: 524e68b7bb39b5acb883ddcbbbf3afd6531dfbc3892abfdf7346e8a97452e51d
5
5
  SHA512:
6
- metadata.gz: df16c6657287cdd6c3c1a717dd7e2e6ab20e64d53a910dc77b9b8f3b7a6dd9a20c3c9330e4d272ce3230f497ef1a936de184a41b35105af15c7a6d27f50c4c90
7
- data.tar.gz: 0ea2cd3c43c44d3ec0c6881558f407fbf0368abceeb66f022f121a45be16aa49d7e23b64f5c66479b9ad804dc07ba36fce78952de603a17f6bc2185ed3fac69d
6
+ metadata.gz: 132445c4a4c05bd1ce60d552c0c6809df5c92cb850c79243cd26fd5552f5db73e3a1b93dbce1585cddec77ff764d33b1bfb7a868d1907dfa37145a1762530729
7
+ data.tar.gz: e399041d7bf61d00d80fe824daeb72e8d008927cd8cd5958aedce23f100e53ecef2887393d0aca753bafc9fed1c4330bd8696ffdcd6a6e69829331efd28e8e22
data/edn-abnf.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "edn-abnf"
3
- s.version = "0.0.10"
3
+ s.version = "0.0.11"
4
4
  s.summary = "CDDL (Concise Data Definition Language) converters and miscellaneous tools"
5
5
  s.description = %q{edn-abnf implements converters and miscellaneous tools for CBOR EDN's ABNF}
6
6
  s.author = "Carsten Bormann"
@@ -289,13 +289,13 @@ module EDNGRAMMAR
289
289
  r0
290
290
  end
291
291
 
292
- module String0
292
+ module String10
293
293
  def spec
294
294
  elements[1]
295
295
  end
296
296
  end
297
297
 
298
- module String1
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 _nt_string
307
+ def _nt_string1
308
308
  start_index = index
309
- if node_cache[:string].has_key?(index)
310
- cached = node_cache[:string][index]
309
+ if node_cache[:string1].has_key?(index)
310
+ cached = node_cache[:string1][index]
311
311
  if cached
312
- node_cache[:string][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
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(String0)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edn-abnf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann