cbor-diag 0.1.5 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cbor-diag.gemspec +1 -1
- data/lib/cbor-diag-parser.rb +740 -57
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22c36d8aa85fc04cdf37ca11218c7665d659a60d
|
4
|
+
data.tar.gz: 62b8bd6567f5749883aa48fb05978a389e04fa9b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc82632b8b0fe411a73ac15f3dd9f45233575cf5bb0812732059d71dae10adccc3c24243820b23b39b0a92ea985b57208767851dc19e8ec1d667df1b7f4f4532
|
7
|
+
data.tar.gz: 883cf391dd38d6b217e015519e4c5bde3018a59e6cf64d1256d4d99f9e4c464e2f7feb3d7bf1beb80e2bac14e1e1e158014db6c8e3d449db17352c04f3594a20
|
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.
|
3
|
+
s.version = "0.2.0"
|
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
@@ -104,28 +104,34 @@ module CBOR_DIAG
|
|
104
104
|
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
105
105
|
r0 = r6
|
106
106
|
else
|
107
|
-
r7 =
|
107
|
+
r7 = _nt_bstring
|
108
108
|
if r7
|
109
109
|
r7 = SyntaxNode.new(input, (index-1)...index) if r7 == true
|
110
110
|
r0 = r7
|
111
111
|
else
|
112
|
-
r8 =
|
112
|
+
r8 = _nt_b64string
|
113
113
|
if r8
|
114
114
|
r8 = SyntaxNode.new(input, (index-1)...index) if r8 == true
|
115
115
|
r0 = r8
|
116
116
|
else
|
117
|
-
r9 =
|
117
|
+
r9 = _nt_array
|
118
118
|
if r9
|
119
119
|
r9 = SyntaxNode.new(input, (index-1)...index) if r9 == true
|
120
120
|
r0 = r9
|
121
121
|
else
|
122
|
-
r10 =
|
122
|
+
r10 = _nt_map
|
123
123
|
if r10
|
124
124
|
r10 = SyntaxNode.new(input, (index-1)...index) if r10 == true
|
125
125
|
r0 = r10
|
126
126
|
else
|
127
|
-
|
128
|
-
|
127
|
+
r11 = _nt_streamstring
|
128
|
+
if r11
|
129
|
+
r11 = SyntaxNode.new(input, (index-1)...index) if r11 == true
|
130
|
+
r0 = r11
|
131
|
+
else
|
132
|
+
@index = i0
|
133
|
+
r0 = nil
|
134
|
+
end
|
129
135
|
end
|
130
136
|
end
|
131
137
|
end
|
@@ -1180,20 +1186,622 @@ module CBOR_DIAG
|
|
1180
1186
|
r0
|
1181
1187
|
end
|
1182
1188
|
|
1183
|
-
module
|
1189
|
+
module Bstring0
|
1190
|
+
def s
|
1191
|
+
elements[1]
|
1192
|
+
end
|
1193
|
+
|
1194
|
+
end
|
1195
|
+
|
1196
|
+
module Bstring1
|
1197
|
+
#'
|
1198
|
+
def to_rb
|
1199
|
+
s.elements.map(&:partval).join.b
|
1200
|
+
end
|
1201
|
+
end
|
1202
|
+
|
1203
|
+
def _nt_bstring
|
1204
|
+
start_index = index
|
1205
|
+
if node_cache[:bstring].has_key?(index)
|
1206
|
+
cached = node_cache[:bstring][index]
|
1207
|
+
if cached
|
1208
|
+
node_cache[:bstring][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1209
|
+
@index = cached.interval.end
|
1210
|
+
end
|
1211
|
+
return cached
|
1212
|
+
end
|
1213
|
+
|
1214
|
+
i0, s0 = index, []
|
1215
|
+
if (match_len = has_terminal?("'", false, index))
|
1216
|
+
r1 = true
|
1217
|
+
@index += match_len
|
1218
|
+
else
|
1219
|
+
terminal_parse_failure('"\'"')
|
1220
|
+
r1 = nil
|
1221
|
+
end
|
1222
|
+
s0 << r1
|
1223
|
+
if r1
|
1224
|
+
s2, i2 = [], index
|
1225
|
+
loop do
|
1226
|
+
r3 = _nt_string_part1
|
1227
|
+
if r3
|
1228
|
+
s2 << r3
|
1229
|
+
else
|
1230
|
+
break
|
1231
|
+
end
|
1232
|
+
end
|
1233
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1234
|
+
s0 << r2
|
1235
|
+
if r2
|
1236
|
+
if (match_len = has_terminal?("'", false, index))
|
1237
|
+
r4 = true
|
1238
|
+
@index += match_len
|
1239
|
+
else
|
1240
|
+
terminal_parse_failure('"\'"')
|
1241
|
+
r4 = nil
|
1242
|
+
end
|
1243
|
+
s0 << r4
|
1244
|
+
end
|
1245
|
+
end
|
1246
|
+
if s0.last
|
1247
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1248
|
+
r0.extend(Bstring0)
|
1249
|
+
r0.extend(Bstring1)
|
1250
|
+
else
|
1251
|
+
@index = i0
|
1252
|
+
r0 = nil
|
1253
|
+
end
|
1254
|
+
|
1255
|
+
node_cache[:bstring][start_index] = r0
|
1256
|
+
|
1257
|
+
r0
|
1258
|
+
end
|
1259
|
+
|
1260
|
+
module StringPart10
|
1261
|
+
def partval; text_value end
|
1262
|
+
end
|
1263
|
+
|
1264
|
+
module StringPart11
|
1265
|
+
def s
|
1266
|
+
elements[1]
|
1267
|
+
end
|
1268
|
+
end
|
1269
|
+
|
1270
|
+
module StringPart12
|
1271
|
+
#"
|
1272
|
+
def partval
|
1273
|
+
v = s.text_value
|
1274
|
+
{"b" => "\b", "f" => "\f", "n" => "\n", "r" => "\r", "t" => "\t"}[v] || v
|
1275
|
+
end
|
1276
|
+
end
|
1277
|
+
|
1278
|
+
module StringPart13
|
1279
|
+
end
|
1280
|
+
|
1281
|
+
module StringPart14
|
1282
|
+
end
|
1283
|
+
|
1284
|
+
module StringPart15
|
1285
|
+
def s
|
1286
|
+
elements[1]
|
1287
|
+
end
|
1288
|
+
|
1289
|
+
def t
|
1290
|
+
elements[3]
|
1291
|
+
end
|
1292
|
+
end
|
1293
|
+
|
1294
|
+
module StringPart16
|
1295
|
+
def partval; (((s.text_value.to_i(16) & 0x3FF) << 10) +
|
1296
|
+
(t.text_value.to_i(16) & 0x3FF) + 0x10000).chr(Encoding::UTF_8) end
|
1297
|
+
end
|
1298
|
+
|
1299
|
+
module StringPart17
|
1300
|
+
end
|
1301
|
+
|
1302
|
+
module StringPart18
|
1303
|
+
end
|
1304
|
+
|
1305
|
+
module StringPart19
|
1306
|
+
def s
|
1307
|
+
elements[1]
|
1308
|
+
end
|
1309
|
+
end
|
1310
|
+
|
1311
|
+
module StringPart110
|
1312
|
+
def partval; s.text_value.to_i(16).chr(Encoding::UTF_8) end
|
1313
|
+
end
|
1314
|
+
|
1315
|
+
def _nt_string_part1
|
1316
|
+
start_index = index
|
1317
|
+
if node_cache[:string_part1].has_key?(index)
|
1318
|
+
cached = node_cache[:string_part1][index]
|
1319
|
+
if cached
|
1320
|
+
node_cache[:string_part1][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1321
|
+
@index = cached.interval.end
|
1322
|
+
end
|
1323
|
+
return cached
|
1324
|
+
end
|
1325
|
+
|
1326
|
+
i0 = index
|
1327
|
+
s1, i1 = [], index
|
1328
|
+
loop do
|
1329
|
+
if has_terminal?(@regexps[gr = '\A[^\\\\\']'] ||= Regexp.new(gr), :regexp, index)
|
1330
|
+
r2 = true
|
1331
|
+
@index += 1
|
1332
|
+
else
|
1333
|
+
terminal_parse_failure('[^\\\\\']')
|
1334
|
+
r2 = nil
|
1335
|
+
end
|
1336
|
+
if r2
|
1337
|
+
s1 << r2
|
1338
|
+
else
|
1339
|
+
break
|
1340
|
+
end
|
1341
|
+
end
|
1342
|
+
if s1.empty?
|
1343
|
+
@index = i1
|
1344
|
+
r1 = nil
|
1345
|
+
else
|
1346
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
1347
|
+
r1.extend(StringPart10)
|
1348
|
+
end
|
1349
|
+
if r1
|
1350
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
1351
|
+
r0 = r1
|
1352
|
+
else
|
1353
|
+
i3, s3 = index, []
|
1354
|
+
if (match_len = has_terminal?("\\", false, index))
|
1355
|
+
r4 = true
|
1356
|
+
@index += match_len
|
1357
|
+
else
|
1358
|
+
terminal_parse_failure('"\\\\"')
|
1359
|
+
r4 = nil
|
1360
|
+
end
|
1361
|
+
s3 << r4
|
1362
|
+
if r4
|
1363
|
+
if has_terminal?(@regexps[gr = '\A["\\\\/bfnrt]'] ||= Regexp.new(gr), :regexp, index)
|
1364
|
+
r5 = true
|
1365
|
+
@index += 1
|
1366
|
+
else
|
1367
|
+
terminal_parse_failure('["\\\\/bfnrt]')
|
1368
|
+
r5 = nil
|
1369
|
+
end
|
1370
|
+
s3 << r5
|
1371
|
+
end
|
1372
|
+
if s3.last
|
1373
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1374
|
+
r3.extend(StringPart11)
|
1375
|
+
r3.extend(StringPart12)
|
1376
|
+
else
|
1377
|
+
@index = i3
|
1378
|
+
r3 = nil
|
1379
|
+
end
|
1380
|
+
if r3
|
1381
|
+
r3 = SyntaxNode.new(input, (index-1)...index) if r3 == true
|
1382
|
+
r0 = r3
|
1383
|
+
else
|
1384
|
+
i6, s6 = index, []
|
1385
|
+
if (match_len = has_terminal?("\\u", false, index))
|
1386
|
+
r7 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1387
|
+
@index += match_len
|
1388
|
+
else
|
1389
|
+
terminal_parse_failure('"\\\\u"')
|
1390
|
+
r7 = nil
|
1391
|
+
end
|
1392
|
+
s6 << r7
|
1393
|
+
if r7
|
1394
|
+
i8, s8 = index, []
|
1395
|
+
if has_terminal?(@regexps[gr = '\A[dD]'] ||= Regexp.new(gr), :regexp, index)
|
1396
|
+
r9 = true
|
1397
|
+
@index += 1
|
1398
|
+
else
|
1399
|
+
terminal_parse_failure('[dD]')
|
1400
|
+
r9 = nil
|
1401
|
+
end
|
1402
|
+
s8 << r9
|
1403
|
+
if r9
|
1404
|
+
if has_terminal?(@regexps[gr = '\A[89abAB]'] ||= Regexp.new(gr), :regexp, index)
|
1405
|
+
r10 = true
|
1406
|
+
@index += 1
|
1407
|
+
else
|
1408
|
+
terminal_parse_failure('[89abAB]')
|
1409
|
+
r10 = nil
|
1410
|
+
end
|
1411
|
+
s8 << r10
|
1412
|
+
if r10
|
1413
|
+
s11, i11 = [], index
|
1414
|
+
loop do
|
1415
|
+
if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
|
1416
|
+
r12 = true
|
1417
|
+
@index += 1
|
1418
|
+
else
|
1419
|
+
terminal_parse_failure('[0-9a-fA-F]')
|
1420
|
+
r12 = nil
|
1421
|
+
end
|
1422
|
+
if r12
|
1423
|
+
s11 << r12
|
1424
|
+
else
|
1425
|
+
break
|
1426
|
+
end
|
1427
|
+
if s11.size == 2
|
1428
|
+
break
|
1429
|
+
end
|
1430
|
+
end
|
1431
|
+
if s11.size < 2
|
1432
|
+
@index = i11
|
1433
|
+
r11 = nil
|
1434
|
+
else
|
1435
|
+
if s11.size < 2
|
1436
|
+
terminal_failures.pop
|
1437
|
+
end
|
1438
|
+
r11 = instantiate_node(SyntaxNode,input, i11...index, s11)
|
1439
|
+
end
|
1440
|
+
s8 << r11
|
1441
|
+
end
|
1442
|
+
end
|
1443
|
+
if s8.last
|
1444
|
+
r8 = instantiate_node(SyntaxNode,input, i8...index, s8)
|
1445
|
+
r8.extend(StringPart13)
|
1446
|
+
else
|
1447
|
+
@index = i8
|
1448
|
+
r8 = nil
|
1449
|
+
end
|
1450
|
+
s6 << r8
|
1451
|
+
if r8
|
1452
|
+
if (match_len = has_terminal?("\\u", false, index))
|
1453
|
+
r13 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1454
|
+
@index += match_len
|
1455
|
+
else
|
1456
|
+
terminal_parse_failure('"\\\\u"')
|
1457
|
+
r13 = nil
|
1458
|
+
end
|
1459
|
+
s6 << r13
|
1460
|
+
if r13
|
1461
|
+
i14, s14 = index, []
|
1462
|
+
if has_terminal?(@regexps[gr = '\A[dD]'] ||= Regexp.new(gr), :regexp, index)
|
1463
|
+
r15 = true
|
1464
|
+
@index += 1
|
1465
|
+
else
|
1466
|
+
terminal_parse_failure('[dD]')
|
1467
|
+
r15 = nil
|
1468
|
+
end
|
1469
|
+
s14 << r15
|
1470
|
+
if r15
|
1471
|
+
if has_terminal?(@regexps[gr = '\A[cCdDeEfF]'] ||= Regexp.new(gr), :regexp, index)
|
1472
|
+
r16 = true
|
1473
|
+
@index += 1
|
1474
|
+
else
|
1475
|
+
terminal_parse_failure('[cCdDeEfF]')
|
1476
|
+
r16 = nil
|
1477
|
+
end
|
1478
|
+
s14 << r16
|
1479
|
+
if r16
|
1480
|
+
s17, i17 = [], index
|
1481
|
+
loop do
|
1482
|
+
if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
|
1483
|
+
r18 = true
|
1484
|
+
@index += 1
|
1485
|
+
else
|
1486
|
+
terminal_parse_failure('[0-9a-fA-F]')
|
1487
|
+
r18 = nil
|
1488
|
+
end
|
1489
|
+
if r18
|
1490
|
+
s17 << r18
|
1491
|
+
else
|
1492
|
+
break
|
1493
|
+
end
|
1494
|
+
if s17.size == 2
|
1495
|
+
break
|
1496
|
+
end
|
1497
|
+
end
|
1498
|
+
if s17.size < 2
|
1499
|
+
@index = i17
|
1500
|
+
r17 = nil
|
1501
|
+
else
|
1502
|
+
if s17.size < 2
|
1503
|
+
terminal_failures.pop
|
1504
|
+
end
|
1505
|
+
r17 = instantiate_node(SyntaxNode,input, i17...index, s17)
|
1506
|
+
end
|
1507
|
+
s14 << r17
|
1508
|
+
end
|
1509
|
+
end
|
1510
|
+
if s14.last
|
1511
|
+
r14 = instantiate_node(SyntaxNode,input, i14...index, s14)
|
1512
|
+
r14.extend(StringPart14)
|
1513
|
+
else
|
1514
|
+
@index = i14
|
1515
|
+
r14 = nil
|
1516
|
+
end
|
1517
|
+
s6 << r14
|
1518
|
+
end
|
1519
|
+
end
|
1520
|
+
end
|
1521
|
+
if s6.last
|
1522
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
1523
|
+
r6.extend(StringPart15)
|
1524
|
+
r6.extend(StringPart16)
|
1525
|
+
else
|
1526
|
+
@index = i6
|
1527
|
+
r6 = nil
|
1528
|
+
end
|
1529
|
+
if r6
|
1530
|
+
r6 = SyntaxNode.new(input, (index-1)...index) if r6 == true
|
1531
|
+
r0 = r6
|
1532
|
+
else
|
1533
|
+
i19, s19 = index, []
|
1534
|
+
if (match_len = has_terminal?("\\u", false, index))
|
1535
|
+
r20 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
1536
|
+
@index += match_len
|
1537
|
+
else
|
1538
|
+
terminal_parse_failure('"\\\\u"')
|
1539
|
+
r20 = nil
|
1540
|
+
end
|
1541
|
+
s19 << r20
|
1542
|
+
if r20
|
1543
|
+
i21 = index
|
1544
|
+
i22, s22 = index, []
|
1545
|
+
if has_terminal?(@regexps[gr = '\A[0-9abcefABCEF]'] ||= Regexp.new(gr), :regexp, index)
|
1546
|
+
r23 = true
|
1547
|
+
@index += 1
|
1548
|
+
else
|
1549
|
+
terminal_parse_failure('[0-9abcefABCEF]')
|
1550
|
+
r23 = nil
|
1551
|
+
end
|
1552
|
+
s22 << r23
|
1553
|
+
if r23
|
1554
|
+
s24, i24 = [], index
|
1555
|
+
loop do
|
1556
|
+
if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
|
1557
|
+
r25 = true
|
1558
|
+
@index += 1
|
1559
|
+
else
|
1560
|
+
terminal_parse_failure('[0-9a-fA-F]')
|
1561
|
+
r25 = nil
|
1562
|
+
end
|
1563
|
+
if r25
|
1564
|
+
s24 << r25
|
1565
|
+
else
|
1566
|
+
break
|
1567
|
+
end
|
1568
|
+
if s24.size == 3
|
1569
|
+
break
|
1570
|
+
end
|
1571
|
+
end
|
1572
|
+
if s24.size < 3
|
1573
|
+
@index = i24
|
1574
|
+
r24 = nil
|
1575
|
+
else
|
1576
|
+
if s24.size < 3
|
1577
|
+
terminal_failures.pop
|
1578
|
+
end
|
1579
|
+
r24 = instantiate_node(SyntaxNode,input, i24...index, s24)
|
1580
|
+
end
|
1581
|
+
s22 << r24
|
1582
|
+
end
|
1583
|
+
if s22.last
|
1584
|
+
r22 = instantiate_node(SyntaxNode,input, i22...index, s22)
|
1585
|
+
r22.extend(StringPart17)
|
1586
|
+
else
|
1587
|
+
@index = i22
|
1588
|
+
r22 = nil
|
1589
|
+
end
|
1590
|
+
if r22
|
1591
|
+
r22 = SyntaxNode.new(input, (index-1)...index) if r22 == true
|
1592
|
+
r21 = r22
|
1593
|
+
else
|
1594
|
+
i26, s26 = index, []
|
1595
|
+
if has_terminal?(@regexps[gr = '\A[dD]'] ||= Regexp.new(gr), :regexp, index)
|
1596
|
+
r27 = true
|
1597
|
+
@index += 1
|
1598
|
+
else
|
1599
|
+
terminal_parse_failure('[dD]')
|
1600
|
+
r27 = nil
|
1601
|
+
end
|
1602
|
+
s26 << r27
|
1603
|
+
if r27
|
1604
|
+
if has_terminal?(@regexps[gr = '\A[0-7]'] ||= Regexp.new(gr), :regexp, index)
|
1605
|
+
r28 = true
|
1606
|
+
@index += 1
|
1607
|
+
else
|
1608
|
+
terminal_parse_failure('[0-7]')
|
1609
|
+
r28 = nil
|
1610
|
+
end
|
1611
|
+
s26 << r28
|
1612
|
+
if r28
|
1613
|
+
s29, i29 = [], index
|
1614
|
+
loop do
|
1615
|
+
if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
|
1616
|
+
r30 = true
|
1617
|
+
@index += 1
|
1618
|
+
else
|
1619
|
+
terminal_parse_failure('[0-9a-fA-F]')
|
1620
|
+
r30 = nil
|
1621
|
+
end
|
1622
|
+
if r30
|
1623
|
+
s29 << r30
|
1624
|
+
else
|
1625
|
+
break
|
1626
|
+
end
|
1627
|
+
if s29.size == 2
|
1628
|
+
break
|
1629
|
+
end
|
1630
|
+
end
|
1631
|
+
if s29.size < 2
|
1632
|
+
@index = i29
|
1633
|
+
r29 = nil
|
1634
|
+
else
|
1635
|
+
if s29.size < 2
|
1636
|
+
terminal_failures.pop
|
1637
|
+
end
|
1638
|
+
r29 = instantiate_node(SyntaxNode,input, i29...index, s29)
|
1639
|
+
end
|
1640
|
+
s26 << r29
|
1641
|
+
end
|
1642
|
+
end
|
1643
|
+
if s26.last
|
1644
|
+
r26 = instantiate_node(SyntaxNode,input, i26...index, s26)
|
1645
|
+
r26.extend(StringPart18)
|
1646
|
+
else
|
1647
|
+
@index = i26
|
1648
|
+
r26 = nil
|
1649
|
+
end
|
1650
|
+
if r26
|
1651
|
+
r26 = SyntaxNode.new(input, (index-1)...index) if r26 == true
|
1652
|
+
r21 = r26
|
1653
|
+
else
|
1654
|
+
@index = i21
|
1655
|
+
r21 = nil
|
1656
|
+
end
|
1657
|
+
end
|
1658
|
+
s19 << r21
|
1659
|
+
end
|
1660
|
+
if s19.last
|
1661
|
+
r19 = instantiate_node(SyntaxNode,input, i19...index, s19)
|
1662
|
+
r19.extend(StringPart19)
|
1663
|
+
r19.extend(StringPart110)
|
1664
|
+
else
|
1665
|
+
@index = i19
|
1666
|
+
r19 = nil
|
1667
|
+
end
|
1668
|
+
if r19
|
1669
|
+
r19 = SyntaxNode.new(input, (index-1)...index) if r19 == true
|
1670
|
+
r0 = r19
|
1671
|
+
else
|
1672
|
+
@index = i0
|
1673
|
+
r0 = nil
|
1674
|
+
end
|
1675
|
+
end
|
1676
|
+
end
|
1677
|
+
end
|
1678
|
+
|
1679
|
+
node_cache[:string_part1][start_index] = r0
|
1680
|
+
|
1681
|
+
r0
|
1184
1682
|
end
|
1185
1683
|
|
1186
|
-
module
|
1187
|
-
def
|
1684
|
+
module Hexdigit0
|
1685
|
+
def dig
|
1686
|
+
elements[0]
|
1687
|
+
end
|
1688
|
+
end
|
1689
|
+
|
1690
|
+
module Hexdigit1
|
1691
|
+
def sval; dig.text_value end
|
1692
|
+
end
|
1693
|
+
|
1694
|
+
def _nt_hexdigit
|
1695
|
+
start_index = index
|
1696
|
+
if node_cache[:hexdigit].has_key?(index)
|
1697
|
+
cached = node_cache[:hexdigit][index]
|
1698
|
+
if cached
|
1699
|
+
node_cache[:hexdigit][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1700
|
+
@index = cached.interval.end
|
1701
|
+
end
|
1702
|
+
return cached
|
1703
|
+
end
|
1704
|
+
|
1705
|
+
i0, s0 = index, []
|
1706
|
+
if has_terminal?(@regexps[gr = '\A[0-9a-fA-F]'] ||= Regexp.new(gr), :regexp, index)
|
1707
|
+
r1 = true
|
1708
|
+
@index += 1
|
1709
|
+
else
|
1710
|
+
terminal_parse_failure('[0-9a-fA-F]')
|
1711
|
+
r1 = nil
|
1712
|
+
end
|
1713
|
+
s0 << r1
|
1714
|
+
if s0.last
|
1715
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1716
|
+
r0.extend(Hexdigit0)
|
1717
|
+
r0.extend(Hexdigit1)
|
1718
|
+
else
|
1719
|
+
@index = i0
|
1720
|
+
r0 = nil
|
1721
|
+
end
|
1722
|
+
|
1723
|
+
node_cache[:hexdigit][start_index] = r0
|
1724
|
+
|
1725
|
+
r0
|
1726
|
+
end
|
1727
|
+
|
1728
|
+
module Twohex0
|
1729
|
+
def s1
|
1730
|
+
elements[0]
|
1731
|
+
end
|
1732
|
+
|
1733
|
+
def ows1
|
1734
|
+
elements[1]
|
1735
|
+
end
|
1736
|
+
|
1737
|
+
def s2
|
1738
|
+
elements[2]
|
1739
|
+
end
|
1740
|
+
|
1741
|
+
def ows2
|
1742
|
+
elements[3]
|
1743
|
+
end
|
1744
|
+
end
|
1745
|
+
|
1746
|
+
module Twohex1
|
1747
|
+
def bval; (s1.sval << s2.sval).to_i(16).chr(Encoding::BINARY) end
|
1748
|
+
end
|
1749
|
+
|
1750
|
+
def _nt_twohex
|
1751
|
+
start_index = index
|
1752
|
+
if node_cache[:twohex].has_key?(index)
|
1753
|
+
cached = node_cache[:twohex][index]
|
1754
|
+
if cached
|
1755
|
+
node_cache[:twohex][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1756
|
+
@index = cached.interval.end
|
1757
|
+
end
|
1758
|
+
return cached
|
1759
|
+
end
|
1760
|
+
|
1761
|
+
i0, s0 = index, []
|
1762
|
+
r1 = _nt_hexdigit
|
1763
|
+
s0 << r1
|
1764
|
+
if r1
|
1765
|
+
r2 = _nt_ows
|
1766
|
+
s0 << r2
|
1767
|
+
if r2
|
1768
|
+
r3 = _nt_hexdigit
|
1769
|
+
s0 << r3
|
1770
|
+
if r3
|
1771
|
+
r4 = _nt_ows
|
1772
|
+
s0 << r4
|
1773
|
+
end
|
1774
|
+
end
|
1775
|
+
end
|
1776
|
+
if s0.last
|
1777
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1778
|
+
r0.extend(Twohex0)
|
1779
|
+
r0.extend(Twohex1)
|
1780
|
+
else
|
1781
|
+
@index = i0
|
1782
|
+
r0 = nil
|
1783
|
+
end
|
1784
|
+
|
1785
|
+
node_cache[:twohex][start_index] = r0
|
1786
|
+
|
1787
|
+
r0
|
1788
|
+
end
|
1789
|
+
|
1790
|
+
module Hstring0
|
1791
|
+
def ows
|
1188
1792
|
elements[1]
|
1189
1793
|
end
|
1190
1794
|
|
1795
|
+
def s
|
1796
|
+
elements[2]
|
1797
|
+
end
|
1798
|
+
|
1191
1799
|
end
|
1192
1800
|
|
1193
|
-
module
|
1801
|
+
module Hstring1
|
1194
1802
|
#"
|
1195
1803
|
def to_rb;
|
1196
|
-
s.
|
1804
|
+
s.elements.map(&:bval).join.b
|
1197
1805
|
end
|
1198
1806
|
end
|
1199
1807
|
|
@@ -1218,57 +1826,36 @@ module CBOR_DIAG
|
|
1218
1826
|
end
|
1219
1827
|
s0 << r1
|
1220
1828
|
if r1
|
1221
|
-
|
1222
|
-
|
1223
|
-
|
1224
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1228
|
-
|
1229
|
-
|
1829
|
+
r2 = _nt_ows
|
1830
|
+
s0 << r2
|
1831
|
+
if r2
|
1832
|
+
s3, i3 = [], index
|
1833
|
+
loop do
|
1834
|
+
r4 = _nt_twohex
|
1835
|
+
if r4
|
1836
|
+
s3 << r4
|
1837
|
+
else
|
1838
|
+
break
|
1839
|
+
end
|
1230
1840
|
end
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
1841
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1842
|
+
s0 << r3
|
1843
|
+
if r3
|
1844
|
+
if (match_len = has_terminal?("'", false, index))
|
1234
1845
|
r5 = true
|
1235
|
-
@index +=
|
1846
|
+
@index += match_len
|
1236
1847
|
else
|
1237
|
-
terminal_parse_failure('
|
1848
|
+
terminal_parse_failure('"\'"')
|
1238
1849
|
r5 = nil
|
1239
1850
|
end
|
1240
|
-
|
1241
|
-
end
|
1242
|
-
if s3.last
|
1243
|
-
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
1244
|
-
r3.extend(Hstring0)
|
1245
|
-
else
|
1246
|
-
@index = i3
|
1247
|
-
r3 = nil
|
1248
|
-
end
|
1249
|
-
if r3
|
1250
|
-
s2 << r3
|
1251
|
-
else
|
1252
|
-
break
|
1253
|
-
end
|
1254
|
-
end
|
1255
|
-
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1256
|
-
s0 << r2
|
1257
|
-
if r2
|
1258
|
-
if (match_len = has_terminal?("'", false, index))
|
1259
|
-
r6 = true
|
1260
|
-
@index += match_len
|
1261
|
-
else
|
1262
|
-
terminal_parse_failure('"\'"')
|
1263
|
-
r6 = nil
|
1851
|
+
s0 << r5
|
1264
1852
|
end
|
1265
|
-
s0 << r6
|
1266
1853
|
end
|
1267
1854
|
end
|
1268
1855
|
if s0.last
|
1269
1856
|
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
1857
|
+
r0.extend(Hstring0)
|
1270
1858
|
r0.extend(Hstring1)
|
1271
|
-
r0.extend(Hstring2)
|
1272
1859
|
else
|
1273
1860
|
@index = i0
|
1274
1861
|
r0 = nil
|
@@ -1807,6 +2394,16 @@ module CBOR_DIAG
|
|
1807
2394
|
r0
|
1808
2395
|
end
|
1809
2396
|
|
2397
|
+
module Ows0
|
2398
|
+
end
|
2399
|
+
|
2400
|
+
module Ows1
|
2401
|
+
end
|
2402
|
+
|
2403
|
+
module Ows2
|
2404
|
+
def sval; "" end
|
2405
|
+
end
|
2406
|
+
|
1810
2407
|
def _nt_ows
|
1811
2408
|
start_index = index
|
1812
2409
|
if node_cache[:ows].has_key?(index)
|
@@ -1818,22 +2415,108 @@ module CBOR_DIAG
|
|
1818
2415
|
return cached
|
1819
2416
|
end
|
1820
2417
|
|
1821
|
-
|
2418
|
+
i0, s0 = index, []
|
2419
|
+
s1, i1 = [], index
|
1822
2420
|
loop do
|
1823
2421
|
if has_terminal?(@regexps[gr = '\A[ \\t\\n\\r]'] ||= Regexp.new(gr), :regexp, index)
|
1824
|
-
|
2422
|
+
r2 = true
|
1825
2423
|
@index += 1
|
1826
2424
|
else
|
1827
2425
|
terminal_parse_failure('[ \\t\\n\\r]')
|
1828
|
-
|
2426
|
+
r2 = nil
|
1829
2427
|
end
|
1830
|
-
if
|
1831
|
-
|
2428
|
+
if r2
|
2429
|
+
s1 << r2
|
1832
2430
|
else
|
1833
2431
|
break
|
1834
2432
|
end
|
1835
2433
|
end
|
1836
|
-
|
2434
|
+
r1 = instantiate_node(SyntaxNode,input, i1...index, s1)
|
2435
|
+
s0 << r1
|
2436
|
+
if r1
|
2437
|
+
s3, i3 = [], index
|
2438
|
+
loop do
|
2439
|
+
i4, s4 = index, []
|
2440
|
+
if (match_len = has_terminal?("/", false, index))
|
2441
|
+
r5 = true
|
2442
|
+
@index += match_len
|
2443
|
+
else
|
2444
|
+
terminal_parse_failure('"/"')
|
2445
|
+
r5 = nil
|
2446
|
+
end
|
2447
|
+
s4 << r5
|
2448
|
+
if r5
|
2449
|
+
s6, i6 = [], index
|
2450
|
+
loop do
|
2451
|
+
if has_terminal?(@regexps[gr = '\A[^/]'] ||= Regexp.new(gr), :regexp, index)
|
2452
|
+
r7 = true
|
2453
|
+
@index += 1
|
2454
|
+
else
|
2455
|
+
terminal_parse_failure('[^/]')
|
2456
|
+
r7 = nil
|
2457
|
+
end
|
2458
|
+
if r7
|
2459
|
+
s6 << r7
|
2460
|
+
else
|
2461
|
+
break
|
2462
|
+
end
|
2463
|
+
end
|
2464
|
+
r6 = instantiate_node(SyntaxNode,input, i6...index, s6)
|
2465
|
+
s4 << r6
|
2466
|
+
if r6
|
2467
|
+
if (match_len = has_terminal?("/", false, index))
|
2468
|
+
r8 = true
|
2469
|
+
@index += match_len
|
2470
|
+
else
|
2471
|
+
terminal_parse_failure('"/"')
|
2472
|
+
r8 = nil
|
2473
|
+
end
|
2474
|
+
s4 << r8
|
2475
|
+
if r8
|
2476
|
+
s9, i9 = [], index
|
2477
|
+
loop do
|
2478
|
+
if has_terminal?(@regexps[gr = '\A[ \\t\\n\\r]'] ||= Regexp.new(gr), :regexp, index)
|
2479
|
+
r10 = true
|
2480
|
+
@index += 1
|
2481
|
+
else
|
2482
|
+
terminal_parse_failure('[ \\t\\n\\r]')
|
2483
|
+
r10 = nil
|
2484
|
+
end
|
2485
|
+
if r10
|
2486
|
+
s9 << r10
|
2487
|
+
else
|
2488
|
+
break
|
2489
|
+
end
|
2490
|
+
end
|
2491
|
+
r9 = instantiate_node(SyntaxNode,input, i9...index, s9)
|
2492
|
+
s4 << r9
|
2493
|
+
end
|
2494
|
+
end
|
2495
|
+
end
|
2496
|
+
if s4.last
|
2497
|
+
r4 = instantiate_node(SyntaxNode,input, i4...index, s4)
|
2498
|
+
r4.extend(Ows0)
|
2499
|
+
else
|
2500
|
+
@index = i4
|
2501
|
+
r4 = nil
|
2502
|
+
end
|
2503
|
+
if r4
|
2504
|
+
s3 << r4
|
2505
|
+
else
|
2506
|
+
break
|
2507
|
+
end
|
2508
|
+
end
|
2509
|
+
r3 = instantiate_node(SyntaxNode,input, i3...index, s3)
|
2510
|
+
s0 << r3
|
2511
|
+
end
|
2512
|
+
if s0.last
|
2513
|
+
r0 = instantiate_node(SyntaxNode,input, i0...index, s0)
|
2514
|
+
r0.extend(Ows1)
|
2515
|
+
r0.extend(Ows2)
|
2516
|
+
else
|
2517
|
+
@index = i0
|
2518
|
+
r0 = nil
|
2519
|
+
end
|
1837
2520
|
|
1838
2521
|
node_cache[:ows][start_index] = r0
|
1839
2522
|
|
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.
|
4
|
+
version: 0.2.0
|
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-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|