edn-abnf 0.5.8 → 0.5.9

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: 74a7d7e1c31717d2f7a42f5d44199b54066a5acdb4b624a2cc961ba02356df53
4
- data.tar.gz: b229fcd8f8d792363ec1a05af94f6619a22630b52e36c01574e232d204a3e82d
3
+ metadata.gz: 806ffbc9b5f1324cd2ae94381fc1260144ed5a8dc62c29a45d42335fb5424a19
4
+ data.tar.gz: bcfcf9de27c7fe957601ee45ba33dec200314ddab4015543cf2f76aec39a3c6a
5
5
  SHA512:
6
- metadata.gz: 65241c695737a54fd4e4496bd463bbfeec7a257f9a82e900f6f85f45c698dbf6b5dd49fcabd0db4775d057a11675d3a17e164a22949ed3f79176d5cbfc99b544
7
- data.tar.gz: bcc298642bb1ab8f8f456b76c6e7c7139bc2e96aeeffdf312869119352fa7580e369e4db28122db008d673a20f7018c6beb1927ec07a581effb615338dc3d14a
6
+ metadata.gz: d3897fe3c7e47eadb5d3d29b90ed663d397254b802ce5fe54b493dbf75a1d3a808b04426e80c5b5e15410ab75d60056b4ca0f7a8b165140a4ba72ff49950cace
7
+ data.tar.gz: 6aab126c0f00fc8b2b6b43bffb9bd8902c79f6ae3df2fa1f6b7a866d277ed27825aa8f48d20294b24e44f62f4d5b7b9a6452a6e33bcb234476449a9901c0b827
data/bin/edn-abnf CHANGED
@@ -57,6 +57,10 @@ begin
57
57
  opts.on("-i", "--[no-]integrated", "use integrated parsers where available") do |v|
58
58
  $options.integrated = v
59
59
  end
60
+ opts.on("--[no-]level", "use separate level shifter") do |v|
61
+ $options.level = v
62
+ $stdout.sync = true
63
+ end
60
64
  opts.on("-eEDN", "--e=EDN", "supply EDN on command line") do |v|
61
65
  $options.edn = v
62
66
  end
data/edn-abnf.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "edn-abnf"
3
- s.version = "0.5.8"
3
+ s.version = "0.5.9"
4
4
  s.summary = "CBOR Extended Diagnostic Notation (EDN) implemented in ABNF"
5
5
  s.description = %q{edn-abnf implements converters and miscellaneous tools for CBOR EDN's ABNF}
6
6
  s.author = "Carsten Bormann"
@@ -41,19 +41,45 @@ class Treetop::Runtime::SyntaxNode
41
41
  end
42
42
  def app_parser_level1_diagnostics(e, node)
43
43
  outbytes = 0
44
- intv = node.interval.end...(node.interval.end+1) # default: closing '
45
- node.elements.each_with_index do |el, i|
46
- outbytes += el.ast.size
47
- if outbytes > e.position
48
- intv = el.interval
49
- break
44
+ if $options.level # do manual level-shifting
45
+ input = node.input
46
+ ol1pos = l1pos = node.interval.begin
47
+ while outbytes <= e.position
48
+ outbytes += 1
49
+ ol1pos = l1pos
50
+ c1 = input[l1pos]
51
+ if c1 == "\\" # escapable-s
52
+ c2 = input[l1pos += 1]
53
+ if c2 == "u" # hexchar-s
54
+ c3 = input[l1pos += 1]
55
+ if c3 == "{"
56
+ l1pos = input.index("}", l1pos)
57
+ else
58
+ if (input[l1pos, 4].to_i(16) & 0xFC00) == 0xD800 # high-surrogate
59
+ l1pos += 6 # low-surrogate
60
+ end
61
+ l1pos += 3 # non-surrogate
62
+ end
63
+ end
64
+ end
65
+ l1pos += 1
66
+ end
67
+ intv = ol1pos...l1pos
68
+ else
69
+ intv = node.interval.end...(node.interval.end+1) # default: closing '
70
+ node.elements.each_with_index do |el, i|
71
+ outbytes += el.ast.size
72
+ if outbytes > e.position
73
+ intv = el.interval
74
+ break
75
+ end
50
76
  end
51
77
  end
52
78
  failure_index = intv.begin
53
79
  failure_line = node.input.line_of(failure_index)
54
80
  failure_column = node.input.column_of(failure_index)
81
+ reason = "** Line #{failure_line}, column #{failure_column}:\n"
55
82
  if line = node.input.lines.to_a[failure_line - 1]
56
- reason = "** Line #{failure_line}, column #{failure_column}:\n"
57
83
  reason << line
58
84
  reason << "\n#{'~' * (failure_column - 1)}#{'^' * intv.size}"
59
85
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edn-abnf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.8
4
+ version: 0.5.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carsten Bormann
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-07-05 00:00:00.000000000 Z
10
+ date: 2025-07-08 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: bundler