parsanol 1.3.74-arm-linux → 1.3.75-arm-linux
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/lib/parsanol/3.2/parsanol_native.so +0 -0
- data/lib/parsanol/3.3/parsanol_native.so +0 -0
- data/lib/parsanol/3.4/parsanol_native.so +0 -0
- data/lib/parsanol/4.0/parsanol_native.so +0 -0
- data/lib/parsanol/atoms/constant.rb +26 -0
- data/lib/parsanol/atoms/lookbehind.rb +32 -0
- data/lib/parsanol/atoms.rb +2 -0
- data/lib/parsanol/native/libparsanol.so +0 -0
- data/lib/parsanol/native/parser.rb +7 -0
- data/lib/parsanol/native/serializer.rb +36 -0
- data/lib/parsanol/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4199b78dc8200a8a90795c96bace54501aadb60429056af97862088d582940f5
|
|
4
|
+
data.tar.gz: fa8a6a0f2517ea649f9a958ab359ffc6b631074a771f8664d4b1d02ee9c2fa9d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 660a66463a938caf83903dd6478fc855bccc58897ef03620e53298844424cc88ba52f2a2c0fcf11223d7ae5315a1e284f36d73dc0b8d895e6b185801dd18cec8
|
|
7
|
+
data.tar.gz: bf43ca3a6d4f8cb67251a2476e4bc89766f9c0b4bc3c39b5cf68289f4163156a9a47754857745f278c85258c8d281dab79bc14c760183c0b3b17586621d8c3dc
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Parsanol
|
|
4
|
+
module Atoms
|
|
5
|
+
# Matches empty and yields a constant value (coradoc-markdown
|
|
6
|
+
# Output parity, rs#137 follow-up): the native wire carries the
|
|
7
|
+
# value as wire data, so constant-yielding grammar shapes parse
|
|
8
|
+
# on both engines with identical trees.
|
|
9
|
+
class Constant < Base
|
|
10
|
+
attr_reader :value
|
|
11
|
+
|
|
12
|
+
def initialize(value)
|
|
13
|
+
super()
|
|
14
|
+
@value = value
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def try(_source, _context, _consume_all)
|
|
18
|
+
[true, @value]
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def to_s_inner(_prec)
|
|
22
|
+
"constant(#{@value.inspect})"
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Parsanol
|
|
4
|
+
module Atoms
|
|
5
|
+
# Inspects the byte window behind the current position: the
|
|
6
|
+
# previous +count+ bytes must equal +pattern+ (positive) or
|
|
7
|
+
# differ (negative). Consumes nothing, yields nil — the
|
|
8
|
+
# precedes?/does_not_precede? guard shape (coradoc-markdown
|
|
9
|
+
# parity, rs#137 follow-up).
|
|
10
|
+
class Lookbehind < Base
|
|
11
|
+
attr_reader :count, :pattern, :positive
|
|
12
|
+
|
|
13
|
+
def initialize(count, pattern, positive: true)
|
|
14
|
+
super()
|
|
15
|
+
@count = count
|
|
16
|
+
@pattern = pattern
|
|
17
|
+
@positive = positive
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def try(source, _context, _consume_all)
|
|
21
|
+
start = source.bytepos
|
|
22
|
+
behind = start >= @count ? source.input.byteslice(start - @count, @count) : nil
|
|
23
|
+
matched = !behind.nil? && behind == @pattern.b
|
|
24
|
+
[matched == @positive, nil]
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def to_s_inner(_prec)
|
|
28
|
+
"lookbehind(#{@count}, #{@pattern.inspect}, #{@positive ? '+' : '-'})"
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/lib/parsanol/atoms.rb
CHANGED
|
@@ -30,6 +30,8 @@ module Parsanol
|
|
|
30
30
|
require "parsanol/atoms/trivia"
|
|
31
31
|
require "parsanol/atoms/named"
|
|
32
32
|
require "parsanol/atoms/lookahead"
|
|
33
|
+
require "parsanol/atoms/constant"
|
|
34
|
+
require "parsanol/atoms/lookbehind"
|
|
33
35
|
require "parsanol/atoms/cut"
|
|
34
36
|
require "parsanol/atoms/alternative"
|
|
35
37
|
require "parsanol/atoms/sequence"
|
|
Binary file
|
|
@@ -191,6 +191,13 @@ module Parsanol
|
|
|
191
191
|
when ::Parsanol::Atoms::Lookahead
|
|
192
192
|
[:lookahead, atom.positive,
|
|
193
193
|
atom_structure(atom.bound_parslet, visited)]
|
|
194
|
+
when ::Parsanol::Atoms::Constant
|
|
195
|
+
# The value differentiates otherwise-identical constant
|
|
196
|
+
# atoms — without it every Constant hashes alike and the
|
|
197
|
+
# grammar cache serves the first wire forever.
|
|
198
|
+
[:constant, atom.value.inspect]
|
|
199
|
+
when ::Parsanol::Atoms::Lookbehind
|
|
200
|
+
[:lookbehind, atom.count, atom.pattern, atom.positive]
|
|
194
201
|
else
|
|
195
202
|
[:unknown, atom.class.name]
|
|
196
203
|
end
|
|
@@ -18,6 +18,10 @@ module Parsanol
|
|
|
18
18
|
def initialize
|
|
19
19
|
@atoms = []
|
|
20
20
|
@atom_cache = {} # object_id => atom_id for deduplication
|
|
21
|
+
# Strong retention: cache keys are object_ids; without holding the
|
|
22
|
+
# atoms, the GC can free one and a later allocation reuses its id,
|
|
23
|
+
# aliasing to a stale wire atom (the #138 recycled-id class).
|
|
24
|
+
@retained_atoms = []
|
|
21
25
|
end
|
|
22
26
|
|
|
23
27
|
# Main serialization method
|
|
@@ -94,6 +98,20 @@ module Parsanol
|
|
|
94
98
|
# reject skip-carrying artifacts loudly (unknown
|
|
95
99
|
# variant), which is the declared gate.
|
|
96
100
|
serialize_trivia(atom)
|
|
101
|
+
when Parsanol::Atoms::Constant
|
|
102
|
+
# rs#137 follow-up: coradoc-markdown's Output
|
|
103
|
+
# atoms — empty match yielding a wire constant.
|
|
104
|
+
{ "Constant" => { "value" => serialize_constant_value(atom.value) } }
|
|
105
|
+
when Parsanol::Atoms::Lookbehind
|
|
106
|
+
# rs#137 follow-up: the precedes?/does_not_precede?
|
|
107
|
+
# guards — inspect the bytes behind the position.
|
|
108
|
+
{
|
|
109
|
+
"Lookbehind" => {
|
|
110
|
+
"count" => atom.count,
|
|
111
|
+
"pattern" => atom.pattern,
|
|
112
|
+
"positive" => atom.positive,
|
|
113
|
+
},
|
|
114
|
+
}
|
|
97
115
|
when Parsanol::Atoms::Ignored
|
|
98
116
|
serialize_ignored(atom)
|
|
99
117
|
else
|
|
@@ -104,6 +122,7 @@ module Parsanol
|
|
|
104
122
|
# Now reserve an atom_id and cache
|
|
105
123
|
atom_id = @atoms.size
|
|
106
124
|
@atom_cache[cache_key] = atom_id
|
|
125
|
+
@retained_atoms << atom
|
|
107
126
|
@atoms << serialized
|
|
108
127
|
|
|
109
128
|
atom_id
|
|
@@ -179,6 +198,7 @@ module Parsanol
|
|
|
179
198
|
# This prevents infinite recursion when a rule references itself
|
|
180
199
|
atom_id = @atoms.size
|
|
181
200
|
@atom_cache[cache_key] = atom_id
|
|
201
|
+
@retained_atoms << atom
|
|
182
202
|
|
|
183
203
|
# Add a placeholder that will be replaced
|
|
184
204
|
@atoms << nil
|
|
@@ -292,6 +312,22 @@ module Parsanol
|
|
|
292
312
|
"parse this grammar with mode: :ruby"
|
|
293
313
|
end
|
|
294
314
|
|
|
315
|
+
def serialize_constant_value(value)
|
|
316
|
+
case value
|
|
317
|
+
when nil then "Nil" # unit variant serializes as the bare tag
|
|
318
|
+
when true, false then { "Bool" => value }
|
|
319
|
+
when Integer then { "Int" => value }
|
|
320
|
+
when String then { "Str" => value }
|
|
321
|
+
when Array then { "Array" => value.map { |v| serialize_constant_value(v) } }
|
|
322
|
+
when Hash
|
|
323
|
+
{ "Hash" => value.map { |k, v| [k.to_s, serialize_constant_value(v)] } }
|
|
324
|
+
else
|
|
325
|
+
raise UnsupportedGrammar,
|
|
326
|
+
"constant atoms carry nil/bool/int/string/array/hash values " \
|
|
327
|
+
"(got #{value.class}); restructure the grammar for native parsing"
|
|
328
|
+
end
|
|
329
|
+
end
|
|
330
|
+
|
|
295
331
|
def serialize_trivia_capture(atom)
|
|
296
332
|
inner_id = serialize_atom(atom.wrapped_atom)
|
|
297
333
|
{
|
data/lib/parsanol/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: parsanol
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.75
|
|
5
5
|
platform: arm-linux
|
|
6
6
|
authors:
|
|
7
7
|
- Ribose Inc.
|
|
@@ -37,6 +37,7 @@ files:
|
|
|
37
37
|
- lib/parsanol/atoms/base.rb
|
|
38
38
|
- lib/parsanol/atoms/can_flatten.rb
|
|
39
39
|
- lib/parsanol/atoms/capture.rb
|
|
40
|
+
- lib/parsanol/atoms/constant.rb
|
|
40
41
|
- lib/parsanol/atoms/context.rb
|
|
41
42
|
- lib/parsanol/atoms/context_optimized.rb
|
|
42
43
|
- lib/parsanol/atoms/custom.rb
|
|
@@ -47,6 +48,7 @@ files:
|
|
|
47
48
|
- lib/parsanol/atoms/ignored.rb
|
|
48
49
|
- lib/parsanol/atoms/infix.rb
|
|
49
50
|
- lib/parsanol/atoms/lookahead.rb
|
|
51
|
+
- lib/parsanol/atoms/lookbehind.rb
|
|
50
52
|
- lib/parsanol/atoms/named.rb
|
|
51
53
|
- lib/parsanol/atoms/re.rb
|
|
52
54
|
- lib/parsanol/atoms/repetition.rb
|