cddl 0.8.24 → 0.8.27

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2c1f0547764e58450c649bbea75add7bdced3de13d209e2889245f9f93ccc32
4
- data.tar.gz: '053925690f1ff8bd8511aaf7879fb0c6ff012357e2b5cb2f66d268e7c8ee6e3d'
3
+ metadata.gz: 2ecd9496de4033983eac3321d6cda899c4e948656e06fe48d6bc5e5b9d8e3942
4
+ data.tar.gz: c117ef0c739d0c9d3967532c57a23aec3dd796c0191a8afb1eb03ee3aae4bd9d
5
5
  SHA512:
6
- metadata.gz: 340381df7522af59ae8bdf637dd7a0731e623f0d36645592c6d1488d2a247d88e612850884f20a27940b9aa66e5174a931ef7d0575ba04bb412070a635706083
7
- data.tar.gz: 64ef37b0a90f0b569fc24dfecf3c968296ac3a07602638ee48cf62273d7eecad801d28a1a83efe3b4db1a2ae9234cf97d703a02292ffafdaf480320440a5840a
6
+ metadata.gz: 2454be6a2b39855ef2d2111c5b5ef98066e32c078ea2ada8ae911c9b0c08fc48cc85c60bead949ab04f5bb7ed4499193283f0abb92296486ec797e48ef1ceb07
7
+ data.tar.gz: 370c93eec6ffc637d4814a81336ebca143ef334a3fad807a2f213104d5ae5051277fbe7d8db19d406e4bde675ff6d993c171f2b5532ff91e64803254f18ec258
data/bin/cddl CHANGED
@@ -19,17 +19,19 @@ def usage
19
19
  exit EX_USAGE
20
20
  end
21
21
 
22
- def read_arg(arg)
22
+ def read_arg(arg, remember_fn = true)
23
23
  if arg == "-"
24
+ $fn = "(stdin)" if remember_fn
24
25
  STDIN.read
25
26
  else
26
27
  usage unless arg
28
+ $fn = arg if remember_fn
27
29
  File.read(arg, mode: "rb")
28
30
  end
29
31
  end
30
32
 
31
33
  def parser
32
- @parser ||= CDDL::Parser.new(read_arg(ARGV[0]))
34
+ @parser ||= CDDL::Parser.new(read_arg(ARGV[0], false))
33
35
  end
34
36
 
35
37
  def my_pp(v)
data/cddl.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  spec = Gem::Specification.new do |s|
2
2
  s.name = 'cddl'
3
- s.version = '0.8.24'
3
+ s.version = '0.8.27'
4
4
  s.summary = "CDDL generator and validator."
5
5
  s.description = %{A parser, generator, and validator for CDDL}
6
6
  s.add_dependency('cbor-diag')
data/lib/cbor-pp-play.rb CHANGED
@@ -2,6 +2,7 @@ require_relative "cbor-pp"
2
2
 
3
3
  a = [1, {foo: "bar", busel: "basel", baz: "bass", ant: "cat", bat: "dog", eel: "fox"},
4
4
  2, 3, 4, [3]*55, "foo".b, 0.00006103515625, 0.0000099, 1e-7, nil]
5
+ a[0].cbor_annotation_add "flurp"
5
6
  a[1].cbor_annotation_add "fasel"
6
7
  CBOR::PP.pp a
7
8
 
data/lib/cddl.rb CHANGED
@@ -463,7 +463,10 @@ module CDDL
463
463
  when :cat, :det
464
464
  lhs = generate1(target, inmap)
465
465
  rhs = generate1(control)
466
- rhs = remove_indentation(rhs) if conop == :det
466
+ if conop == :det
467
+ lhs = remove_indentation(lhs)
468
+ rhs = remove_indentation(rhs)
469
+ end
467
470
  begin
468
471
  lhs + rhs
469
472
  rescue Exception => e
@@ -531,6 +534,7 @@ module CDDL
531
534
  unless !bytes.nil? && String === grammar
532
535
  fail "Don't know yet how to generate #{where}"
533
536
  end
537
+ grammar << "\n" unless grammar =~ /\n\z/
534
538
  out = ABNF_PARSER_FOR_STRING[grammar].generate
535
539
  if conop == :abnfb
536
540
  out = out.codepoints.pack("C*")
@@ -611,7 +615,10 @@ module CDDL
611
615
  elsif vt1 == Float
612
616
  [true, v1 + v2, vt1] if vt2 == Integer || vt2 == Float
613
617
  else
614
- v2 = remove_indentation(v2) if conop == :det
618
+ if conop == :det
619
+ v1 = remove_indentation(v1)
620
+ v2 = remove_indentation(v2)
621
+ end
615
622
  [true, v1 + v2, vt1] if vt1 == vt2
616
623
  end
617
624
  end rescue nil
@@ -643,7 +650,7 @@ module CDDL
643
650
  ok = ENV["CDDL_FEATURE_OK"] and ok = ok.split(/,\s*/) or ok = []
644
651
  # warn([:OK, ok, $features].inspect)
645
652
  features = $features.reject {|k, v| ok.include? k.to_s }
646
- warn "** Features potentially used: #{features.map {|k, v| "#{k}: #{v.keys}"}.join(", ")}" if features != {}
653
+ warn "** Features potentially used (#$fn): #{features.map {|k, v| "#{k}: #{v.keys}"}.join(", ")}" if features != {}
647
654
  end
648
655
  else
649
656
  warn "CDDL validation failure (#{result.inspect} for #{d.inspect}):"
@@ -854,13 +861,16 @@ module CDDL
854
861
  [] if where[2] === d && where[1].include?(d)
855
862
  when :anno
856
863
  _, conop, target, control = where
857
- if conop == :cat || conop == :plus
864
+ if conop == :cat || conop == :plus || conop == :det
858
865
  ok1, v1, vt1 = extract_value(target)
859
866
  ok2, v2, vt2 = extract_value(control)
860
867
  # warn ["ANNO0", ok1, v1, vt1, ok2, v2, vt2, d].inspect
861
868
  if ok1 && ok2
862
869
  v2 = Integer(v2) if vt1 == Integer
863
- v2 = remove_indentation(v2) if conop == :det
870
+ if conop == :det
871
+ v1 = remove_indentation(v1)
872
+ v2 = remove_indentation(v2)
873
+ end
864
874
  # warn ["ANNO", ok1, v1, vt1, ok2, v2, vt2, d].inspect
865
875
  [] if d == v1 + v2 # XXX Focus ArgumentError
866
876
  end
@@ -909,11 +919,13 @@ module CDDL
909
919
  if ok
910
920
  nm = v
911
921
  det = d
922
+ warn "*** feature controller should be a string: #{control.inspect}" unless String == vt
912
923
  else
913
924
  ok, *v = extract_array(control)
914
925
  if ok && v.size == 2
915
926
  nm = v[0][0]
916
927
  det = v[1][0]
928
+ warn "*** first element of feature controller should be a string: #{control.inspect}" unless String === nm
917
929
  else
918
930
  warn "*** feature controller not implemented: #{control.inspect}"
919
931
  end
@@ -0,0 +1,12 @@
1
+ bar = ["" .cat foo, "" .cat cbor-tags-oid]
2
+
3
+ foo = '' .det cbor-tags-oid
4
+
5
+ cbor-tags-oid = '
6
+ oid = 1*arc
7
+ roid = *arc
8
+ arc = [nlsb] %x00-7f
9
+ nlsb = %x81-ff *%x80-ff
10
+ ' .det ''
11
+
12
+ cbor-tags-oid-decrypted = cbor-tags-oid .det (([]) .det ([]))
@@ -0,0 +1,6 @@
1
+ a = b .feature 3
2
+ b = c .feature 3.3
3
+ c = d .feature (["drei", "ok"])
4
+ d = e .feature ([[], "ok"])
5
+ e = f .feature ([1, "ok"])
6
+ f = int .feature (1)
@@ -0,0 +1 @@
1
+ a = text .regexp "[a-z][a-z0-9]*(-[a-z0-9]+)*"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cddl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.24
4
+ version: 0.8.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-04-09 00:00:00.000000000 Z
11
+ date: 2022-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cbor-diag
@@ -135,9 +135,11 @@ files:
135
135
  - test-data/cose.cddl
136
136
  - test-data/dcaf.cddl
137
137
  - test-data/dcaf1.cddl
138
+ - test-data/det1.cddl
138
139
  - test-data/dotsize.cddl
139
140
  - test-data/extractor-demo.cddl
140
141
  - test-data/feat1.cddl
142
+ - test-data/feature-controller.cddl
141
143
  - test-data/feature-detail.cddl
142
144
  - test-data/foo.cddl
143
145
  - test-data/grasp-01-extract.cddl
@@ -193,6 +195,7 @@ files:
193
195
  - test-data/wrong2.cddl
194
196
  - test-data/wrong2a.cddl
195
197
  - test-data/xmlmig.cddl
198
+ - test-data/yangid.cddl
196
199
  - test-data/yaron1.cddl
197
200
  - test/test-cddl.rb
198
201
  homepage: http://github.com/cabo/cddl
@@ -214,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
217
  - !ruby/object:Gem::Version
215
218
  version: '0'
216
219
  requirements: []
217
- rubygems_version: 3.2.3
220
+ rubygems_version: 3.3.3
218
221
  signing_key:
219
222
  specification_version: 4
220
223
  summary: CDDL generator and validator.