edn-abnf 0.5.1 → 0.5.3
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/edn-abnf +15 -2
- data/edn-abnf.gemspec +1 -1
- data/lib/parser/edn-util.rb +9 -0
- data/lib/parser/edngrammar.rb +3316 -550
- 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: 993acf6aae5ce078aec90f346fa8a0a313b33d3af4ef16661fdc6c3d31def17c
|
4
|
+
data.tar.gz: a8504ae9093db0b806ecaec245a8ddee7d9cdabbdace99e12ee9e7240ea35fbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41632492c3f64d9bec1f80db81318d7b0efa35fd9f57e2e12e5bb3f57ced8877a7bb453f1d9d8fd3aea7bb6cd40a95a35ae205f21ec89fa6ebe47a5d01b6daf0
|
7
|
+
data.tar.gz: e0ecb22948210d10f00782f94d4e558b3acdd1f9c63625643cffaad17f8b02e1863d1578e13f5b67ca0abcfa44c0f41f951ed622a86033aaf9aa2dd6942bf63b
|
data/bin/edn-abnf
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
# coding: utf-8
|
2
|
+
# coding: utf-8
|
3
3
|
require 'pp'
|
4
4
|
require 'yaml'
|
5
5
|
require 'treetop'
|
@@ -32,6 +32,8 @@ Encoding.default_external = Encoding::UTF_8
|
|
32
32
|
require 'optparse'
|
33
33
|
require 'ostruct'
|
34
34
|
|
35
|
+
$error = 0
|
36
|
+
|
35
37
|
$options = OpenStruct.new
|
36
38
|
begin
|
37
39
|
op = OptionParser.new do |opts|
|
@@ -100,6 +102,7 @@ if $options.lines
|
|
100
102
|
else
|
101
103
|
puts "** x / #{ednin.inspect} / #{out} ≠ #{result_diag.inspect} / #{result_hex}"
|
102
104
|
end
|
105
|
+
$error += 1
|
103
106
|
end
|
104
107
|
next
|
105
108
|
end
|
@@ -110,17 +113,20 @@ if $options.lines
|
|
110
113
|
diag = result.cbor_diagnostic
|
111
114
|
if out == diag && !ok
|
112
115
|
puts "** ≠ / #{diag.inspect} / #{out.inspect}"
|
116
|
+
$error += 1
|
113
117
|
end
|
114
118
|
if out != diag && ok
|
115
119
|
outdiag = tree_from_edn_possibly_hex(out || "").cbor_diagnostic
|
116
120
|
if outdiag != diag
|
117
121
|
puts "** ≡ / #{ednin.inspect} #{diag.inspect} / #{out.inspect} #{outdiag.inspect}"
|
122
|
+
$error += 1
|
118
123
|
end
|
119
124
|
puts "reparsed / #{diag.inspect} / #{out.inspect}" if $options.verbose
|
120
125
|
end
|
121
126
|
rescue ArgumentError => e
|
122
127
|
if ok
|
123
128
|
puts "** #{e} / #{result.inspect} / #{out.inspect}"
|
129
|
+
$error += 1
|
124
130
|
else
|
125
131
|
if $options.verbose
|
126
132
|
puts "expected failure #{e}"
|
@@ -128,7 +134,14 @@ if $options.lines
|
|
128
134
|
end
|
129
135
|
end
|
130
136
|
end
|
131
|
-
|
137
|
+
if $error > 0
|
138
|
+
puts
|
139
|
+
puts "*** #$error errors!"
|
140
|
+
puts
|
141
|
+
exit 1
|
142
|
+
else
|
143
|
+
exit
|
144
|
+
end
|
132
145
|
end
|
133
146
|
|
134
147
|
begin
|
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.
|
3
|
+
s.version = "0.5.3"
|
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"
|
data/lib/parser/edn-util.rb
CHANGED
@@ -5,6 +5,15 @@ end
|
|
5
5
|
require 'treetop'
|
6
6
|
require_relative './edngrammar'
|
7
7
|
|
8
|
+
module EDNGRAMMAR
|
9
|
+
const_set(:APPS, Hash.new { |h, k|
|
10
|
+
h[k] = begin ::CBOR_DIAG.const_get("App_#{k.downcase}")
|
11
|
+
rescue NameError
|
12
|
+
raise ArgumentError, "cbor-diagnostic: Unknown application-oriented extension '#{k}'", caller
|
13
|
+
end
|
14
|
+
}) unless const_defined?(:APPS)
|
15
|
+
end
|
16
|
+
|
8
17
|
class Treetop::Runtime::SyntaxNode
|
9
18
|
def ast
|
10
19
|
fail "undefined_ast #{inspect}"
|