cddlc 0.4.3 → 0.4.5
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/bin/cddlc +16 -0
- data/cddlc.gemspec +1 -1
- data/lib/cddlc.rb +6 -1
- 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: 1dfe2802ae8527a4b38a7c0c91f62a6aff4fa17043281b0593d40ba1c428a77f
|
|
4
|
+
data.tar.gz: 445a6efba2bf00ac88331e2703da21a5f1a61411bb864d766955f17054509fa5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3306065f415d657586a793ce342db43d9dc1a10d90b6af3bb281368da386226284a5301214831064ec2b7c0a378bd0a7f2f9f4e51a989f1e6ddc8bb9812b0f1b
|
|
7
|
+
data.tar.gz: 3debf194ffee5bf0bb31e9bcf37f1c8c5fe1deb4526be1187cb1ba5fe2afaae044fdc322f64d4e4221406e3a6bdd32d0473a0a066c9d76ea4fa9bf577bc60eb3
|
data/bin/cddlc
CHANGED
|
@@ -42,6 +42,8 @@ require 'optparse'
|
|
|
42
42
|
require 'ostruct'
|
|
43
43
|
|
|
44
44
|
$options = OpenStruct.new
|
|
45
|
+
$options.auto_choices = {}
|
|
46
|
+
|
|
45
47
|
begin
|
|
46
48
|
op = OptionParser.new do |opts|
|
|
47
49
|
opts.banner = "Usage: cddlc [options] [-e cddl | file.cddl... | -]"
|
|
@@ -86,6 +88,10 @@ begin
|
|
|
86
88
|
opts.on("-sRULE", "--start=RULE", String, "Start rule name") do |v|
|
|
87
89
|
$options.start = v
|
|
88
90
|
end
|
|
91
|
+
opts.on("-SRULE", "--start-and-import=RULE", String, "Start rule name and just import from input") do |v|
|
|
92
|
+
$options.start = v
|
|
93
|
+
$options.input = true
|
|
94
|
+
end
|
|
89
95
|
opts.on("-eCDDL", "CDDL model on command line") do |v|
|
|
90
96
|
$options.model = v
|
|
91
97
|
end
|
|
@@ -100,6 +106,12 @@ begin
|
|
|
100
106
|
$options.include ||= []
|
|
101
107
|
$options.include << v
|
|
102
108
|
end
|
|
109
|
+
opts.on("-TRULE", "--type-choice=RULE", String, "Treat multiple assignments to RULE as type choice") do |v|
|
|
110
|
+
$options.auto_choices[v] = ["tcho", "tadd"]
|
|
111
|
+
end
|
|
112
|
+
opts.on("-GRULE", "--group-choice=RULE", String, "Treat multiple assignments to RULE as group choice") do |v|
|
|
113
|
+
$options.auto_choices[v] = ["gcho", "gadd"]
|
|
114
|
+
end
|
|
103
115
|
end
|
|
104
116
|
op.parse!
|
|
105
117
|
rescue StandardError => e
|
|
@@ -117,6 +129,10 @@ end
|
|
|
117
129
|
cddl_file = ""
|
|
118
130
|
if $options.start
|
|
119
131
|
cddl_file << "@.start.@ = #{$options.start}\n"
|
|
132
|
+
if $options.input
|
|
133
|
+
$options.input = ARGF.read
|
|
134
|
+
cddl_file << ";# import /\n"
|
|
135
|
+
end
|
|
120
136
|
end
|
|
121
137
|
if m = $options.model
|
|
122
138
|
cddl_file << m << "\n"
|
data/cddlc.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = "cddlc"
|
|
3
|
-
s.version = "0.4.
|
|
3
|
+
s.version = "0.4.5"
|
|
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
|
@@ -2,6 +2,7 @@ require_relative "parser/cddl-util.rb"
|
|
|
2
2
|
require_relative "processor/cddl-visitor.rb"
|
|
3
3
|
require_relative 'processor/cddl-undefined.rb'
|
|
4
4
|
require_relative 'writer/cddl-writer.rb'
|
|
5
|
+
require 'stringio'
|
|
5
6
|
|
|
6
7
|
class CDDL
|
|
7
8
|
@@parser = CDDLGRAMMARParser.new
|
|
@@ -42,6 +43,9 @@ class CDDL
|
|
|
42
43
|
|
|
43
44
|
def self.read_from_include_path(fn)
|
|
44
45
|
io = nil
|
|
46
|
+
if fn == "/.cddl" # XXX hack in importing from command line files
|
|
47
|
+
return StringIO.new($options.input)
|
|
48
|
+
end
|
|
45
49
|
CDDL::cddl_include_path.each do |path|
|
|
46
50
|
begin
|
|
47
51
|
io = (path + fn).open
|
|
@@ -53,7 +57,7 @@ class CDDL
|
|
|
53
57
|
io
|
|
54
58
|
end
|
|
55
59
|
|
|
56
|
-
SAFE_FN = /\A[-._a-zA-Z0-9]
|
|
60
|
+
SAFE_FN = /\A[-._a-zA-Z0-9]+|\/\z/ # XXX
|
|
57
61
|
IMPINC = /\A(?:import|include)\z/
|
|
58
62
|
IDENTIFIER_RE = /\A[A-Za-z@_$]([-.]*[A-Za-z@_$0-9])*\z/
|
|
59
63
|
INT_RE = /\A0|[-]?[1-9][0-9]*\z/
|
|
@@ -280,6 +284,7 @@ class CDDL
|
|
|
280
284
|
when "name"
|
|
281
285
|
fail unless name.size == 2
|
|
282
286
|
name = name[1]
|
|
287
|
+
cho ||= $options.auto_choices[name] if @rules[name]
|
|
283
288
|
when "gen"
|
|
284
289
|
parmnames = name[2..-1]
|
|
285
290
|
name = name[1] # XXX update val with parm/arg
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: cddlc
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.4.
|
|
4
|
+
version: 0.4.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Carsten Bormann
|
|
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
130
130
|
- !ruby/object:Gem::Version
|
|
131
131
|
version: '0'
|
|
132
132
|
requirements: []
|
|
133
|
-
rubygems_version:
|
|
133
|
+
rubygems_version: 4.0.8
|
|
134
134
|
specification_version: 4
|
|
135
135
|
summary: CDDL (Concise Data Definition Language) converters and miscellaneous tools
|
|
136
136
|
test_files: []
|