cddlc 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/cddlc.gemspec +1 -1
- data/lib/cddlc.rb +4 -3
- data/lib/parser/cddlgrammar.rb +82 -3
- data/lib/processor/cddl-expander.rb +2 -2
- data/lib/processor/cddl-visitor.rb +1 -1
- data/lib/writer/cddl-writer.rb +2 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30602affec27761888bf5f3094ac596e21cbf80fa9726f2476210ed8b419b981
|
4
|
+
data.tar.gz: 4742739b320591da0f59be4732d4c0957acbfc80a1ca699caeda5943007b3d0a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a726e557db0da91370c0c3f22ab31fc7f494d0c6902874b8129c3afb40bffd95855d7785be15f105a3cdc62831a79048daa919f714267e83bd372cf3c455bd1
|
7
|
+
data.tar.gz: a1b74234c1195480fa40eb2e298dcbb2450c07e12e282fbb0606733cf60c716f280a224f33ba5f9baa9e80d0cb1829dff526bbe78f492ae9e7f30a1bff8cc68b
|
data/cddlc.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "cddlc"
|
3
|
-
s.version = "0.1.
|
3
|
+
s.version = "0.1.6"
|
4
4
|
s.summary = "CDDL (Concise Data Definition Language) converters and miscellaneous tools"
|
5
5
|
s.description = %q{cddlc implements converters and miscellaneous tools for CDDL, RFC 8610}
|
6
6
|
s.author = "Carsten Bormann"
|
data/lib/cddlc.rb
CHANGED
@@ -98,9 +98,9 @@ class CDDL
|
|
98
98
|
end
|
99
99
|
end.compact
|
100
100
|
end
|
101
|
-
|
102
|
-
|
103
|
-
|
101
|
+
warn "FROM #{from.inspect}" if $options.verbose
|
102
|
+
warn "PREFERRED_TAG #{preferred_tag.inspect}" if $options.verbose
|
103
|
+
warn "DOCREF #{docref.inspect}" if $options.verbose
|
104
104
|
|
105
105
|
fn = docref.downcase << ".cddl"
|
106
106
|
io = CDDL.read_from_include_path(fn)
|
@@ -162,6 +162,7 @@ class CDDL
|
|
162
162
|
end
|
163
163
|
break unless got_more
|
164
164
|
to_be_imported = cddl_undefined # XXX square...
|
165
|
+
warn "TO IMPORT #{to_be_imported.inspect}" if $options.verbose
|
165
166
|
must_be_found = false
|
166
167
|
end
|
167
168
|
if preferred_tag
|
data/lib/parser/cddlgrammar.rb
CHANGED
@@ -947,7 +947,7 @@ module CDDLGRAMMAR
|
|
947
947
|
end
|
948
948
|
|
949
949
|
module Type214
|
950
|
-
def
|
950
|
+
def tag_number
|
951
951
|
elements[1]
|
952
952
|
end
|
953
953
|
end
|
@@ -970,7 +970,7 @@ module CDDLGRAMMAR
|
|
970
970
|
module Type216
|
971
971
|
def ast
|
972
972
|
el = elements[2].elements
|
973
|
-
["prim", 6, el && el[1].
|
973
|
+
["prim", 6, el && el[1].ast, elements[5].ast]
|
974
974
|
end
|
975
975
|
end
|
976
976
|
|
@@ -1330,7 +1330,7 @@ module CDDLGRAMMAR
|
|
1330
1330
|
end
|
1331
1331
|
s48 << r49
|
1332
1332
|
if r49
|
1333
|
-
r50 =
|
1333
|
+
r50 = _nt_tag_number
|
1334
1334
|
s48 << r50
|
1335
1335
|
end
|
1336
1336
|
if s48.last
|
@@ -1476,6 +1476,85 @@ module CDDLGRAMMAR
|
|
1476
1476
|
r0
|
1477
1477
|
end
|
1478
1478
|
|
1479
|
+
module TagNumber0
|
1480
|
+
def ast() text_value.to_i end
|
1481
|
+
end
|
1482
|
+
|
1483
|
+
module TagNumber1
|
1484
|
+
def type
|
1485
|
+
elements[1]
|
1486
|
+
end
|
1487
|
+
|
1488
|
+
end
|
1489
|
+
|
1490
|
+
module TagNumber2
|
1491
|
+
def ast() elements[1].ast end
|
1492
|
+
end
|
1493
|
+
|
1494
|
+
def _nt_tag_number
|
1495
|
+
start_index = index
|
1496
|
+
if node_cache[:tag_number].has_key?(index)
|
1497
|
+
cached = node_cache[:tag_number][index]
|
1498
|
+
if cached
|
1499
|
+
node_cache[:tag_number][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
1500
|
+
@index = cached.interval.end
|
1501
|
+
end
|
1502
|
+
return cached
|
1503
|
+
end
|
1504
|
+
|
1505
|
+
i0 = index
|
1506
|
+
r1 = _nt_uint
|
1507
|
+
r1.extend(TagNumber0)
|
1508
|
+
r1.extend(TagNumber0)
|
1509
|
+
if r1
|
1510
|
+
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
1511
|
+
r0 = r1
|
1512
|
+
else
|
1513
|
+
i2, s2 = index, []
|
1514
|
+
if (match_len = has_terminal?("<", false, index))
|
1515
|
+
r3 = true
|
1516
|
+
@index += match_len
|
1517
|
+
else
|
1518
|
+
terminal_parse_failure('"<"')
|
1519
|
+
r3 = nil
|
1520
|
+
end
|
1521
|
+
s2 << r3
|
1522
|
+
if r3
|
1523
|
+
r4 = _nt_type
|
1524
|
+
s2 << r4
|
1525
|
+
if r4
|
1526
|
+
if (match_len = has_terminal?(">", false, index))
|
1527
|
+
r5 = true
|
1528
|
+
@index += match_len
|
1529
|
+
else
|
1530
|
+
terminal_parse_failure('">"')
|
1531
|
+
r5 = nil
|
1532
|
+
end
|
1533
|
+
s2 << r5
|
1534
|
+
end
|
1535
|
+
end
|
1536
|
+
if s2.last
|
1537
|
+
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1538
|
+
r2.extend(TagNumber1)
|
1539
|
+
r2.extend(TagNumber2)
|
1540
|
+
else
|
1541
|
+
@index = i2
|
1542
|
+
r2 = nil
|
1543
|
+
end
|
1544
|
+
if r2
|
1545
|
+
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
1546
|
+
r0 = r2
|
1547
|
+
else
|
1548
|
+
@index = i0
|
1549
|
+
r0 = nil
|
1550
|
+
end
|
1551
|
+
end
|
1552
|
+
|
1553
|
+
node_cache[:tag_number][start_index] = r0
|
1554
|
+
|
1555
|
+
r0
|
1556
|
+
end
|
1557
|
+
|
1479
1558
|
def _nt_rangeop
|
1480
1559
|
start_index = index
|
1481
1560
|
if node_cache[:rangeop].has_key?(index)
|
@@ -42,7 +42,7 @@ class CDDL
|
|
42
42
|
else
|
43
43
|
end
|
44
44
|
end
|
45
|
-
|
45
|
+
warn "@gen = #{@gen.inspect}" if $options.verbose
|
46
46
|
@gen.each do |k, v|
|
47
47
|
parmnames = v[0]
|
48
48
|
fail unless rules[k] == ["parm", parmnames, v[1]]
|
@@ -53,7 +53,7 @@ class CDDL
|
|
53
53
|
fail if Array === name
|
54
54
|
@new_rules[name] = expand_prod(prod)
|
55
55
|
end
|
56
|
-
|
56
|
+
warn "@new_rules = #{@new_rules.inspect}" if $options.verbose
|
57
57
|
@rules = @new_rules
|
58
58
|
end
|
59
59
|
end
|
@@ -31,7 +31,7 @@ class CDDL
|
|
31
31
|
["enum", visit(prod, &block)]
|
32
32
|
in ["unwrap", prod]
|
33
33
|
["unwrap", visit(prod, &block)] # XXX, this may need to be bottled in a rule
|
34
|
-
in ["prim",
|
34
|
+
in ["prim", prod, *prods]
|
35
35
|
["prim", visit(prod, &block), *visit_all(prods, &block)]
|
36
36
|
in ["mem", *prods]
|
37
37
|
["mem", *visit_all(prods, &block)]
|
data/lib/writer/cddl-writer.rb
CHANGED
@@ -68,6 +68,8 @@ class CDDL
|
|
68
68
|
[4, "##{maj}.#{min}"]
|
69
69
|
in ["prim", 6, Integer => tag, type]
|
70
70
|
[4, "#6.#{tag}(#{write_rhs(type, 0, indent, pn)})"]
|
71
|
+
in ["prim", 6, Array => tag, type]
|
72
|
+
[4, "#6.<#{write_rhs(tag, 0, indent, pn)}>(#{write_rhs(type, 0, indent, pn)})"]
|
71
73
|
in ["prim", 6, nil, type]
|
72
74
|
[4, "#6(#{write_rhs(type, 0, indent, pn)})"]
|
73
75
|
# prim: extension for #6.<i>(t)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cddlc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
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-03-
|
11
|
+
date: 2023-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|