cbor-diag 0.1.2 → 0.1.3
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/cbor-diag.gemspec +1 -1
- data/lib/cbor-diag-parser.rb +160 -36
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7aa80d45a6ae5f3ed58ba23f627a72783d3ef09e
|
4
|
+
data.tar.gz: fbf6382b6f7351229f470c836395ba14f903a825
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 63eb19bedae2c11b1b687828869af180326e0f562fb9052ed556a6674734fc640cb3abecd55ec595a495a6f0cc7ef99cdcf534fef026b64fe163ae3de0a4a1ad
|
7
|
+
data.tar.gz: d72dd52e82fd8ae59742353b2da6e6d2472218d1931f3eb98a45284eefe75e4e11a27373d35332838e4676c99e0f23430dfe52936d5bfcfcba14e38b037531fe
|
data/cbor-diag.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cbor-diag"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.3"
|
4
4
|
s.summary = "CBOR (Concise Binary Object Representation) diagnostic notation"
|
5
5
|
s.description = %q{cbor-diag implements diagnostic notation for CBOR, RFC 7049}
|
6
6
|
s.author = "Carsten Bormann"
|
data/lib/cbor-diag-parser.rb
CHANGED
@@ -233,7 +233,7 @@ module CBOR_DIAG
|
|
233
233
|
r8 = true
|
234
234
|
@index += match_len
|
235
235
|
else
|
236
|
-
terminal_parse_failure('
|
236
|
+
terminal_parse_failure('\'.\'')
|
237
237
|
r8 = nil
|
238
238
|
end
|
239
239
|
s7 << r8
|
@@ -381,7 +381,7 @@ module CBOR_DIAG
|
|
381
381
|
r1.extend(Infin0)
|
382
382
|
@index += match_len
|
383
383
|
else
|
384
|
-
terminal_parse_failure('Infinity')
|
384
|
+
terminal_parse_failure('\'Infinity\'')
|
385
385
|
r1 = nil
|
386
386
|
end
|
387
387
|
if r1
|
@@ -393,7 +393,7 @@ module CBOR_DIAG
|
|
393
393
|
r2.extend(Infin1)
|
394
394
|
@index += match_len
|
395
395
|
else
|
396
|
-
terminal_parse_failure('-Infinity')
|
396
|
+
terminal_parse_failure('\'-Infinity\'')
|
397
397
|
r2 = nil
|
398
398
|
end
|
399
399
|
if r2
|
@@ -405,7 +405,7 @@ module CBOR_DIAG
|
|
405
405
|
r3.extend(Infin2)
|
406
406
|
@index += match_len
|
407
407
|
else
|
408
|
-
terminal_parse_failure('NaN')
|
408
|
+
terminal_parse_failure('\'NaN\'')
|
409
409
|
r3 = nil
|
410
410
|
end
|
411
411
|
if r3
|
@@ -475,7 +475,7 @@ module CBOR_DIAG
|
|
475
475
|
r1.extend(Simple0)
|
476
476
|
@index += match_len
|
477
477
|
else
|
478
|
-
terminal_parse_failure('false')
|
478
|
+
terminal_parse_failure('\'false\'')
|
479
479
|
r1 = nil
|
480
480
|
end
|
481
481
|
if r1
|
@@ -487,7 +487,7 @@ module CBOR_DIAG
|
|
487
487
|
r2.extend(Simple1)
|
488
488
|
@index += match_len
|
489
489
|
else
|
490
|
-
terminal_parse_failure('true')
|
490
|
+
terminal_parse_failure('\'true\'')
|
491
491
|
r2 = nil
|
492
492
|
end
|
493
493
|
if r2
|
@@ -499,7 +499,7 @@ module CBOR_DIAG
|
|
499
499
|
r3.extend(Simple2)
|
500
500
|
@index += match_len
|
501
501
|
else
|
502
|
-
terminal_parse_failure('null')
|
502
|
+
terminal_parse_failure('\'null\'')
|
503
503
|
r3 = nil
|
504
504
|
end
|
505
505
|
if r3
|
@@ -511,7 +511,7 @@ module CBOR_DIAG
|
|
511
511
|
r4.extend(Simple3)
|
512
512
|
@index += match_len
|
513
513
|
else
|
514
|
-
terminal_parse_failure('undefined')
|
514
|
+
terminal_parse_failure('\'undefined\'')
|
515
515
|
r4 = nil
|
516
516
|
end
|
517
517
|
if r4
|
@@ -523,7 +523,7 @@ module CBOR_DIAG
|
|
523
523
|
r6 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
524
524
|
@index += match_len
|
525
525
|
else
|
526
|
-
terminal_parse_failure('simple(')
|
526
|
+
terminal_parse_failure('\'simple(\'')
|
527
527
|
r6 = nil
|
528
528
|
end
|
529
529
|
s5 << r6
|
@@ -541,7 +541,7 @@ module CBOR_DIAG
|
|
541
541
|
r10 = true
|
542
542
|
@index += match_len
|
543
543
|
else
|
544
|
-
terminal_parse_failure(')')
|
544
|
+
terminal_parse_failure('\')\'')
|
545
545
|
r10 = nil
|
546
546
|
end
|
547
547
|
s5 << r10
|
@@ -638,7 +638,7 @@ module CBOR_DIAG
|
|
638
638
|
r3 = true
|
639
639
|
@index += match_len
|
640
640
|
else
|
641
|
-
terminal_parse_failure('(')
|
641
|
+
terminal_parse_failure('\'(\'')
|
642
642
|
r3 = nil
|
643
643
|
end
|
644
644
|
s0 << r3
|
@@ -656,7 +656,7 @@ module CBOR_DIAG
|
|
656
656
|
r7 = true
|
657
657
|
@index += match_len
|
658
658
|
else
|
659
|
-
terminal_parse_failure(')')
|
659
|
+
terminal_parse_failure('\')\'')
|
660
660
|
r7 = nil
|
661
661
|
end
|
662
662
|
s0 << r7
|
@@ -709,7 +709,7 @@ module CBOR_DIAG
|
|
709
709
|
r1 = true
|
710
710
|
@index += match_len
|
711
711
|
else
|
712
|
-
terminal_parse_failure('"')
|
712
|
+
terminal_parse_failure('\'"\'')
|
713
713
|
r1 = nil
|
714
714
|
end
|
715
715
|
s0 << r1
|
@@ -730,7 +730,7 @@ module CBOR_DIAG
|
|
730
730
|
r4 = true
|
731
731
|
@index += match_len
|
732
732
|
else
|
733
|
-
terminal_parse_failure('"')
|
733
|
+
terminal_parse_failure('\'"\'')
|
734
734
|
r4 = nil
|
735
735
|
end
|
736
736
|
s0 << r4
|
@@ -848,7 +848,7 @@ module CBOR_DIAG
|
|
848
848
|
r4 = true
|
849
849
|
@index += match_len
|
850
850
|
else
|
851
|
-
terminal_parse_failure("
|
851
|
+
terminal_parse_failure('"\\\\"')
|
852
852
|
r4 = nil
|
853
853
|
end
|
854
854
|
s3 << r4
|
@@ -879,7 +879,7 @@ module CBOR_DIAG
|
|
879
879
|
r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
880
880
|
@index += match_len
|
881
881
|
else
|
882
|
-
terminal_parse_failure("
|
882
|
+
terminal_parse_failure('"\\\\u"')
|
883
883
|
r7 = nil
|
884
884
|
end
|
885
885
|
s6 << r7
|
@@ -925,6 +925,9 @@ module CBOR_DIAG
|
|
925
925
|
@index = i11
|
926
926
|
r11 = nil
|
927
927
|
else
|
928
|
+
if s11.size < 2
|
929
|
+
terminal_failures.pop
|
930
|
+
end
|
928
931
|
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
929
932
|
end
|
930
933
|
s8 << r11
|
@@ -943,7 +946,7 @@ module CBOR_DIAG
|
|
943
946
|
r13 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
944
947
|
@index += match_len
|
945
948
|
else
|
946
|
-
terminal_parse_failure("
|
949
|
+
terminal_parse_failure('"\\\\u"')
|
947
950
|
r13 = nil
|
948
951
|
end
|
949
952
|
s6 << r13
|
@@ -989,6 +992,9 @@ module CBOR_DIAG
|
|
989
992
|
@index = i17
|
990
993
|
r17 = nil
|
991
994
|
else
|
995
|
+
if s17.size < 2
|
996
|
+
terminal_failures.pop
|
997
|
+
end
|
992
998
|
r17 = instantiate_node(SyntaxNode,input, i17...index, s17)
|
993
999
|
end
|
994
1000
|
s14 << r17
|
@@ -1022,7 +1028,7 @@ module CBOR_DIAG
|
|
1022
1028
|
r20 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1023
1029
|
@index += match_len
|
1024
1030
|
else
|
1025
|
-
terminal_parse_failure("
|
1031
|
+
terminal_parse_failure('"\\\\u"')
|
1026
1032
|
r20 = nil
|
1027
1033
|
end
|
1028
1034
|
s19 << r20
|
@@ -1060,6 +1066,9 @@ module CBOR_DIAG
|
|
1060
1066
|
@index = i24
|
1061
1067
|
r24 = nil
|
1062
1068
|
else
|
1069
|
+
if s24.size < 3
|
1070
|
+
terminal_failures.pop
|
1071
|
+
end
|
1063
1072
|
r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
|
1064
1073
|
end
|
1065
1074
|
s22 << r24
|
@@ -1116,6 +1125,9 @@ module CBOR_DIAG
|
|
1116
1125
|
@index = i29
|
1117
1126
|
r29 = nil
|
1118
1127
|
else
|
1128
|
+
if s29.size < 2
|
1129
|
+
terminal_failures.pop
|
1130
|
+
end
|
1119
1131
|
r29 = instantiate_node(SyntaxNode,input, i29...index, s29)
|
1120
1132
|
end
|
1121
1133
|
s26 << r29
|
@@ -1195,7 +1207,7 @@ module CBOR_DIAG
|
|
1195
1207
|
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1196
1208
|
@index += match_len
|
1197
1209
|
else
|
1198
|
-
terminal_parse_failure("h'")
|
1210
|
+
terminal_parse_failure('"h\'"')
|
1199
1211
|
r1 = nil
|
1200
1212
|
end
|
1201
1213
|
s0 << r1
|
@@ -1241,7 +1253,7 @@ module CBOR_DIAG
|
|
1241
1253
|
r6 = true
|
1242
1254
|
@index += match_len
|
1243
1255
|
else
|
1244
|
-
terminal_parse_failure("'")
|
1256
|
+
terminal_parse_failure('"\'"')
|
1245
1257
|
r6 = nil
|
1246
1258
|
end
|
1247
1259
|
s0 << r6
|
@@ -1261,6 +1273,118 @@ module CBOR_DIAG
|
|
1261
1273
|
r0
|
1262
1274
|
end
|
1263
1275
|
|
1276
|
+
module Hstring0
|
1277
|
+
end
|
1278
|
+
|
1279
|
+
module Hstring1
|
1280
|
+
def s
|
1281
|
+
elements[1]
|
1282
|
+
end
|
1283
|
+
|
1284
|
+
end
|
1285
|
+
|
1286
|
+
module Hstring2
|
1287
|
+
#"
|
1288
|
+
def to_rb;
|
1289
|
+
t = s.text_value.chars.each_slice(4).map(&:join)
|
1290
|
+
if last = t[-1]
|
1291
|
+
last << "=" * (4 - last.size)
|
1292
|
+
end
|
1293
|
+
t.join.tr("-_", "+/").unpack("m0")[0]
|
1294
|
+
end
|
1295
|
+
end
|
1296
|
+
|
1297
|
+
def _nt_hstring
|
1298
|
+
start_index = index
|
1299
|
+
if node_cache[:hstring].has_key?(index)
|
1300
|
+
cached = node_cache[:hstring][index]
|
1301
|
+
if cached
|
1302
|
+
node_cache[:hstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1303
|
+
@index = cached.interval.end
|
1304
|
+
end
|
1305
|
+
return cached
|
1306
|
+
end
|
1307
|
+
|
1308
|
+
i0, s0 = index, []
|
1309
|
+
if (match_len = has_terminal?("b64'", false, index))
|
1310
|
+
r1 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1311
|
+
@index += match_len
|
1312
|
+
else
|
1313
|
+
terminal_parse_failure('"b64\'"')
|
1314
|
+
r1 = nil
|
1315
|
+
end
|
1316
|
+
s0 << r1
|
1317
|
+
if r1
|
1318
|
+
i2, s2 = index, []
|
1319
|
+
s3, i3 = [], index
|
1320
|
+
loop do
|
1321
|
+
if has_terminal?(@regexps[gr = '\A[0-9a-fA-F_\\-+/]'] ||= Regexp.new(gr), :regexp, index)
|
1322
|
+
r4 = true
|
1323
|
+
@index += 1
|
1324
|
+
else
|
1325
|
+
terminal_parse_failure('[0-9a-fA-F_\\-+/]')
|
1326
|
+
r4 = nil
|
1327
|
+
end
|
1328
|
+
if r4
|
1329
|
+
s3 << r4
|
1330
|
+
else
|
1331
|
+
break
|
1332
|
+
end
|
1333
|
+
end
|
1334
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1335
|
+
s2 << r3
|
1336
|
+
if r3
|
1337
|
+
s5, i5 = [], index
|
1338
|
+
loop do
|
1339
|
+
if has_terminal?(@regexps[gr = '\A[=]'] ||= Regexp.new(gr), :regexp, index)
|
1340
|
+
r6 = true
|
1341
|
+
@index += 1
|
1342
|
+
else
|
1343
|
+
terminal_parse_failure('[=]')
|
1344
|
+
r6 = nil
|
1345
|
+
end
|
1346
|
+
if r6
|
1347
|
+
s5 << r6
|
1348
|
+
else
|
1349
|
+
break
|
1350
|
+
end
|
1351
|
+
end
|
1352
|
+
r5 = instantiate_node(SyntaxNode,input, i5...index, s5)
|
1353
|
+
s2 << r5
|
1354
|
+
end
|
1355
|
+
if s2.last
|
1356
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1357
|
+
r2.extend(Hstring0)
|
1358
|
+
else
|
1359
|
+
@index = i2
|
1360
|
+
r2 = nil
|
1361
|
+
end
|
1362
|
+
s0 << r2
|
1363
|
+
if r2
|
1364
|
+
if (match_len = has_terminal?("'", false, index))
|
1365
|
+
r7 = true
|
1366
|
+
@index += match_len
|
1367
|
+
else
|
1368
|
+
terminal_parse_failure('"\'"')
|
1369
|
+
r7 = nil
|
1370
|
+
end
|
1371
|
+
s0 << r7
|
1372
|
+
end
|
1373
|
+
end
|
1374
|
+
if s0.last
|
1375
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1376
|
+
r0.extend(Hstring1)
|
1377
|
+
r0.extend(Hstring2)
|
1378
|
+
else
|
1379
|
+
@index = i0
|
1380
|
+
r0 = nil
|
1381
|
+
end
|
1382
|
+
|
1383
|
+
node_cache[:hstring][start_index] = r0
|
1384
|
+
|
1385
|
+
r0
|
1386
|
+
end
|
1387
|
+
|
1264
1388
|
module Array0
|
1265
1389
|
def ows1
|
1266
1390
|
elements[1]
|
@@ -1334,7 +1458,7 @@ module CBOR_DIAG
|
|
1334
1458
|
r1 = true
|
1335
1459
|
@index += match_len
|
1336
1460
|
else
|
1337
|
-
terminal_parse_failure('[')
|
1461
|
+
terminal_parse_failure('\'[\'')
|
1338
1462
|
r1 = nil
|
1339
1463
|
end
|
1340
1464
|
s0 << r1
|
@@ -1356,7 +1480,7 @@ module CBOR_DIAG
|
|
1356
1480
|
r9 = true
|
1357
1481
|
@index += match_len
|
1358
1482
|
else
|
1359
|
-
terminal_parse_failure('
|
1483
|
+
terminal_parse_failure('\',\'')
|
1360
1484
|
r9 = nil
|
1361
1485
|
end
|
1362
1486
|
s8 << r9
|
@@ -1410,7 +1534,7 @@ module CBOR_DIAG
|
|
1410
1534
|
r14 = true
|
1411
1535
|
@index += match_len
|
1412
1536
|
else
|
1413
|
-
terminal_parse_failure(']')
|
1537
|
+
terminal_parse_failure('\']\'')
|
1414
1538
|
r14 = nil
|
1415
1539
|
end
|
1416
1540
|
s0 << r14
|
@@ -1505,7 +1629,7 @@ module CBOR_DIAG
|
|
1505
1629
|
r1 = true
|
1506
1630
|
@index += match_len
|
1507
1631
|
else
|
1508
|
-
terminal_parse_failure('{')
|
1632
|
+
terminal_parse_failure('\'{\'')
|
1509
1633
|
r1 = nil
|
1510
1634
|
end
|
1511
1635
|
s0 << r1
|
@@ -1527,7 +1651,7 @@ module CBOR_DIAG
|
|
1527
1651
|
r9 = true
|
1528
1652
|
@index += match_len
|
1529
1653
|
else
|
1530
|
-
terminal_parse_failure('
|
1654
|
+
terminal_parse_failure('\',\'')
|
1531
1655
|
r9 = nil
|
1532
1656
|
end
|
1533
1657
|
s8 << r9
|
@@ -1581,7 +1705,7 @@ module CBOR_DIAG
|
|
1581
1705
|
r14 = true
|
1582
1706
|
@index += match_len
|
1583
1707
|
else
|
1584
|
-
terminal_parse_failure('}')
|
1708
|
+
terminal_parse_failure('\'}\'')
|
1585
1709
|
r14 = nil
|
1586
1710
|
end
|
1587
1711
|
s0 << r14
|
@@ -1649,7 +1773,7 @@ module CBOR_DIAG
|
|
1649
1773
|
r3 = true
|
1650
1774
|
@index += match_len
|
1651
1775
|
else
|
1652
|
-
terminal_parse_failure(":")
|
1776
|
+
terminal_parse_failure('":"')
|
1653
1777
|
r3 = nil
|
1654
1778
|
end
|
1655
1779
|
s0 << r3
|
@@ -1835,7 +1959,7 @@ module CBOR_DIAG
|
|
1835
1959
|
r2 = true
|
1836
1960
|
@index += match_len
|
1837
1961
|
else
|
1838
|
-
terminal_parse_failure('(')
|
1962
|
+
terminal_parse_failure('\'(\'')
|
1839
1963
|
r2 = nil
|
1840
1964
|
end
|
1841
1965
|
s1 << r2
|
@@ -1847,7 +1971,7 @@ module CBOR_DIAG
|
|
1847
1971
|
r4 = true
|
1848
1972
|
@index += match_len
|
1849
1973
|
else
|
1850
|
-
terminal_parse_failure("_")
|
1974
|
+
terminal_parse_failure('"_"')
|
1851
1975
|
r4 = nil
|
1852
1976
|
end
|
1853
1977
|
s1 << r4
|
@@ -1869,7 +1993,7 @@ module CBOR_DIAG
|
|
1869
1993
|
r11 = true
|
1870
1994
|
@index += match_len
|
1871
1995
|
else
|
1872
|
-
terminal_parse_failure(",")
|
1996
|
+
terminal_parse_failure('","')
|
1873
1997
|
r11 = nil
|
1874
1998
|
end
|
1875
1999
|
s10 << r11
|
@@ -1915,7 +2039,7 @@ module CBOR_DIAG
|
|
1915
2039
|
r15 = true
|
1916
2040
|
@index += match_len
|
1917
2041
|
else
|
1918
|
-
terminal_parse_failure(')')
|
2042
|
+
terminal_parse_failure('\')\'')
|
1919
2043
|
r15 = nil
|
1920
2044
|
end
|
1921
2045
|
s1 << r15
|
@@ -1941,7 +2065,7 @@ module CBOR_DIAG
|
|
1941
2065
|
r17 = true
|
1942
2066
|
@index += match_len
|
1943
2067
|
else
|
1944
|
-
terminal_parse_failure('(')
|
2068
|
+
terminal_parse_failure('\'(\'')
|
1945
2069
|
r17 = nil
|
1946
2070
|
end
|
1947
2071
|
s16 << r17
|
@@ -1953,7 +2077,7 @@ module CBOR_DIAG
|
|
1953
2077
|
r19 = true
|
1954
2078
|
@index += match_len
|
1955
2079
|
else
|
1956
|
-
terminal_parse_failure("_")
|
2080
|
+
terminal_parse_failure('"_"')
|
1957
2081
|
r19 = nil
|
1958
2082
|
end
|
1959
2083
|
s16 << r19
|
@@ -1975,7 +2099,7 @@ module CBOR_DIAG
|
|
1975
2099
|
r26 = true
|
1976
2100
|
@index += match_len
|
1977
2101
|
else
|
1978
|
-
terminal_parse_failure(",")
|
2102
|
+
terminal_parse_failure('","')
|
1979
2103
|
r26 = nil
|
1980
2104
|
end
|
1981
2105
|
s25 << r26
|
@@ -2021,7 +2145,7 @@ module CBOR_DIAG
|
|
2021
2145
|
r30 = true
|
2022
2146
|
@index += match_len
|
2023
2147
|
else
|
2024
|
-
terminal_parse_failure(')')
|
2148
|
+
terminal_parse_failure('\')\'')
|
2025
2149
|
r30 = nil
|
2026
2150
|
end
|
2027
2151
|
s16 << r30
|
@@ -2091,7 +2215,7 @@ module CBOR_DIAG
|
|
2091
2215
|
r3 = true
|
2092
2216
|
@index += match_len
|
2093
2217
|
else
|
2094
|
-
terminal_parse_failure("_")
|
2218
|
+
terminal_parse_failure('"_"')
|
2095
2219
|
r3 = nil
|
2096
2220
|
end
|
2097
2221
|
if r3
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cbor-diag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.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: 2015-
|
11
|
+
date: 2015-11-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -105,3 +105,4 @@ signing_key:
|
|
105
105
|
specification_version: 4
|
106
106
|
summary: CBOR (Concise Binary Object Representation) diagnostic notation
|
107
107
|
test_files: []
|
108
|
+
has_rdoc: false
|