edn-abnf 0.3.4 → 0.3.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/edn-abnf +11 -1
- data/edn-abnf.gemspec +1 -1
- data/lib/parser/edngrammar.rb +40 -29
- 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: 5fb3a21c21375974f9e6c3b1f708f002b00aaeaff85e72d430a836ce3e0fd2f7
|
4
|
+
data.tar.gz: fcfc55d388ed1b62ab3ecb4503764cc7eb87c6f984d8082c746705091ad38569
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 329bf4e226c07a53b9103a3f9ef58a70d9c2c539ceb5f50a47c80427362dd7d6b4877c4bb53d11da1c0ce811cdd3fda7296e5994e05822b4a706869760819c34
|
7
|
+
data.tar.gz: 659cc80dc2d1013c6f2176982205c159e0359036888b50152228c52e0e10148109288f88e716191e6a9eeb104e98ec1a610b00f53d7f1546b64d0a6919f56674
|
data/bin/edn-abnf
CHANGED
@@ -4,6 +4,7 @@ require 'pp'
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'treetop'
|
6
6
|
require 'json'
|
7
|
+
require 'cbor-pretty'
|
7
8
|
|
8
9
|
require_relative '../lib/edn-abnf.rb'
|
9
10
|
|
@@ -46,7 +47,9 @@ begin
|
|
46
47
|
opts.on("-eEDN", "--e=EDN", "supply EDN on command line") do |v|
|
47
48
|
$options.edn = v
|
48
49
|
end
|
49
|
-
opts.on("-tFMT", "--to=FMT",
|
50
|
+
opts.on("-tFMT", "--to=FMT",
|
51
|
+
[:basic, :neat, :json, :yaml, :edn, :diag, :pretty],
|
52
|
+
"Target format (default: diag)") do |v|
|
50
53
|
$options.target = v
|
51
54
|
end
|
52
55
|
end
|
@@ -137,6 +140,13 @@ when :yaml
|
|
137
140
|
puts result.to_yaml
|
138
141
|
when :edn, :diag, nil
|
139
142
|
puts result.cbor_diagnostic
|
143
|
+
when :pretty
|
144
|
+
enc = if CBOR::Sequence === result
|
145
|
+
result.to_cborseq
|
146
|
+
else
|
147
|
+
result.to_cbor
|
148
|
+
end
|
149
|
+
puts CBOR::pretty_seq(enc)
|
140
150
|
else
|
141
151
|
warn ["Unknown target format: ", $options.target].inspect
|
142
152
|
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.3.
|
3
|
+
s.version = "0.3.6"
|
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/edngrammar.rb
CHANGED
@@ -1757,6 +1757,13 @@ module EDNGRAMMAR
|
|
1757
1757
|
end
|
1758
1758
|
|
1759
1759
|
module Sqstr0
|
1760
|
+
def SQUOTE1
|
1761
|
+
elements[0]
|
1762
|
+
end
|
1763
|
+
|
1764
|
+
def SQUOTE2
|
1765
|
+
elements[2]
|
1766
|
+
end
|
1760
1767
|
end
|
1761
1768
|
|
1762
1769
|
module Sqstr1
|
@@ -1777,13 +1784,7 @@ module EDNGRAMMAR
|
|
1777
1784
|
end
|
1778
1785
|
|
1779
1786
|
i0, s0 = index, []
|
1780
|
-
|
1781
|
-
r1 = true
|
1782
|
-
@index += match_len
|
1783
|
-
else
|
1784
|
-
terminal_parse_failure('"\'"')
|
1785
|
-
r1 = nil
|
1786
|
-
end
|
1787
|
+
r1 = _nt_SQUOTE
|
1787
1788
|
s0 << r1
|
1788
1789
|
if r1
|
1789
1790
|
s2, i2 = [], index
|
@@ -1798,13 +1799,7 @@ module EDNGRAMMAR
|
|
1798
1799
|
r2 = instantiate_node(SyntaxNode,input, i2...index, s2)
|
1799
1800
|
s0 << r2
|
1800
1801
|
if r2
|
1801
|
-
|
1802
|
-
r4 = true
|
1803
|
-
@index += match_len
|
1804
|
-
else
|
1805
|
-
terminal_parse_failure('"\'"')
|
1806
|
-
r4 = nil
|
1807
|
-
end
|
1802
|
+
r4 = _nt_SQUOTE
|
1808
1803
|
s0 << r4
|
1809
1804
|
end
|
1810
1805
|
end
|
@@ -3067,14 +3062,9 @@ module EDNGRAMMAR
|
|
3067
3062
|
r1 = SyntaxNode.new(input, (index-1)...index) if r1 == true
|
3068
3063
|
r0 = r1
|
3069
3064
|
else
|
3070
|
-
|
3071
|
-
|
3072
|
-
|
3073
|
-
@index += match_len
|
3074
|
-
else
|
3075
|
-
terminal_parse_failure('"\'"')
|
3076
|
-
r2 = nil
|
3077
|
-
end
|
3065
|
+
r2 = _nt_SQUOTE
|
3066
|
+
r2.extend(DoubleQuoted1)
|
3067
|
+
r2.extend(DoubleQuoted1)
|
3078
3068
|
if r2
|
3079
3069
|
r2 = SyntaxNode.new(input, (index-1)...index) if r2 == true
|
3080
3070
|
r0 = r2
|
@@ -3150,6 +3140,9 @@ module EDNGRAMMAR
|
|
3150
3140
|
end
|
3151
3141
|
|
3152
3142
|
module SingleQuoted2
|
3143
|
+
def SQUOTE
|
3144
|
+
elements[1]
|
3145
|
+
end
|
3153
3146
|
end
|
3154
3147
|
|
3155
3148
|
module SingleQuoted3
|
@@ -3202,13 +3195,7 @@ module EDNGRAMMAR
|
|
3202
3195
|
end
|
3203
3196
|
s3 << r4
|
3204
3197
|
if r4
|
3205
|
-
|
3206
|
-
r5 = true
|
3207
|
-
@index += match_len
|
3208
|
-
else
|
3209
|
-
terminal_parse_failure('"\'"')
|
3210
|
-
r5 = nil
|
3211
|
-
end
|
3198
|
+
r5 = _nt_SQUOTE
|
3212
3199
|
s3 << r5
|
3213
3200
|
end
|
3214
3201
|
if s3.last
|
@@ -4319,6 +4306,30 @@ module EDNGRAMMAR
|
|
4319
4306
|
r0
|
4320
4307
|
end
|
4321
4308
|
|
4309
|
+
def _nt_SQUOTE
|
4310
|
+
start_index = index
|
4311
|
+
if node_cache[:SQUOTE].has_key?(index)
|
4312
|
+
cached = node_cache[:SQUOTE][index]
|
4313
|
+
if cached
|
4314
|
+
node_cache[:SQUOTE][index] = cached = SyntaxNode.new(input, index...(index + 1)) if cached == true
|
4315
|
+
@index = cached.interval.end
|
4316
|
+
end
|
4317
|
+
return cached
|
4318
|
+
end
|
4319
|
+
|
4320
|
+
if (match_len = has_terminal?("'", false, index))
|
4321
|
+
r0 = instantiate_node(SyntaxNode,input, index...(index + match_len))
|
4322
|
+
@index += match_len
|
4323
|
+
else
|
4324
|
+
terminal_parse_failure('"\'"')
|
4325
|
+
r0 = nil
|
4326
|
+
end
|
4327
|
+
|
4328
|
+
node_cache[:SQUOTE][start_index] = r0
|
4329
|
+
|
4330
|
+
r0
|
4331
|
+
end
|
4332
|
+
|
4322
4333
|
def _nt_DIGIT
|
4323
4334
|
start_index = index
|
4324
4335
|
if node_cache[:DIGIT].has_key?(index)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: edn-abnf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carsten Bormann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-01-
|
11
|
+
date: 2025-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|