edn-abnf 0.4.2 → 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 +24 -2
- data/edn-abnf.gemspec +1 -1
- data/lib/parser/edn-util.rb +9 -0
- data/lib/parser/edngrammar.rb +3398 -545
- 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|
|
@@ -52,6 +54,15 @@ begin
|
|
52
54
|
"Target format (default: diag)") do |v|
|
53
55
|
$options.target = v
|
54
56
|
end
|
57
|
+
opts.on("-aAPP", "--app=APP", "Load application extension") do |v|
|
58
|
+
v.split(",") do |nm|
|
59
|
+
if nm =~ /\A[a-z][a-z0-9]*\z/
|
60
|
+
require "cbor-diagnostic-app/#{nm}"
|
61
|
+
else
|
62
|
+
raise ArgumentError.new("edn-abnf: app-extension name #{nm} not valid")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
55
66
|
end
|
56
67
|
op.parse!
|
57
68
|
rescue Exception => e
|
@@ -91,6 +102,7 @@ if $options.lines
|
|
91
102
|
else
|
92
103
|
puts "** x / #{ednin.inspect} / #{out} ≠ #{result_diag.inspect} / #{result_hex}"
|
93
104
|
end
|
105
|
+
$error += 1
|
94
106
|
end
|
95
107
|
next
|
96
108
|
end
|
@@ -101,17 +113,20 @@ if $options.lines
|
|
101
113
|
diag = result.cbor_diagnostic
|
102
114
|
if out == diag && !ok
|
103
115
|
puts "** ≠ / #{diag.inspect} / #{out.inspect}"
|
116
|
+
$error += 1
|
104
117
|
end
|
105
118
|
if out != diag && ok
|
106
119
|
outdiag = tree_from_edn_possibly_hex(out || "").cbor_diagnostic
|
107
120
|
if outdiag != diag
|
108
121
|
puts "** ≡ / #{ednin.inspect} #{diag.inspect} / #{out.inspect} #{outdiag.inspect}"
|
122
|
+
$error += 1
|
109
123
|
end
|
110
124
|
puts "reparsed / #{diag.inspect} / #{out.inspect}" if $options.verbose
|
111
125
|
end
|
112
126
|
rescue ArgumentError => e
|
113
127
|
if ok
|
114
128
|
puts "** #{e} / #{result.inspect} / #{out.inspect}"
|
129
|
+
$error += 1
|
115
130
|
else
|
116
131
|
if $options.verbose
|
117
132
|
puts "expected failure #{e}"
|
@@ -119,7 +134,14 @@ if $options.lines
|
|
119
134
|
end
|
120
135
|
end
|
121
136
|
end
|
122
|
-
|
137
|
+
if $error > 0
|
138
|
+
puts
|
139
|
+
puts "*** #$error errors!"
|
140
|
+
puts
|
141
|
+
exit 1
|
142
|
+
else
|
143
|
+
exit
|
144
|
+
end
|
123
145
|
end
|
124
146
|
|
125
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.
|
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}"
|