parsanol 1.3.86 → 1.3.87
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/atoms/base.rb +5 -1
- data/lib/parsanol/skip.rb +19 -5
- data/lib/parsanol/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a0b4e99564a7a93dc454c5e004acb05f2fb6884dc993a75c3eb30565c0360687
|
|
4
|
+
data.tar.gz: 64ce48196a227e8c4f73dbc1d16a5415a278ef8a7730aaa7c8e85b45b28e75b3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2fde0240109a63a418d2851ca9578293934c784a0e14c74ecf74032dab99c361c729fdb468c4a4c8fdbc39e0f836a00a04202ccc7cfc96485230adfe636c7772
|
|
7
|
+
data.tar.gz: 516e9a87cc5577b0f00d1f994783cb0da6132105052f466f3ed4afb45b41445d29234d96443c15e39b1557d14c93395457c10d9bc5b4a2d7d30ef8393dcc4ae1
|
data/lib/parsanol/atoms/base.rb
CHANGED
|
@@ -157,7 +157,11 @@ module Parsanol
|
|
|
157
157
|
# @param outer [Integer] caller's precedence
|
|
158
158
|
# @return [String]
|
|
159
159
|
def to_s(outer = TOP)
|
|
160
|
-
text
|
|
160
|
+
# The inner text is cached per instance: renders walk the atom
|
|
161
|
+
# tree through shared references, and an uncached render is
|
|
162
|
+
# exponential on cross-referencing grammars (parsanol-ruby#190).
|
|
163
|
+
# The paren wrapper stays dynamic; the label is read live.
|
|
164
|
+
text = label || (@to_s_inner_cache ||= to_s_inner(precedence))
|
|
161
165
|
outer < precedence ? "(#{text})" : text
|
|
162
166
|
end
|
|
163
167
|
|
data/lib/parsanol/skip.rb
CHANGED
|
@@ -201,12 +201,26 @@ module Parsanol
|
|
|
201
201
|
when Atoms::Entity
|
|
202
202
|
# Rule bodies own their injection when the grammar declares
|
|
203
203
|
# skip on every rule (PARG); in the DSL surface the root tree
|
|
204
|
-
# is walked once, so
|
|
205
|
-
#
|
|
206
|
-
#
|
|
207
|
-
#
|
|
204
|
+
# is walked once, so inject the resolved body as a fresh
|
|
205
|
+
# injection scope (even inside a repetition interior — the
|
|
206
|
+
# d54a29e exception is for rule-reference children). The
|
|
207
|
+
# reference itself stays an Entity pointing at the injected
|
|
208
|
+
# body: inlining the body into every referencing site makes
|
|
209
|
+
# every rendered string (to_s, and failure messages built
|
|
210
|
+
# from inspect) expand the grammar exponentially on
|
|
211
|
+
# cross-referencing grammars — one failing Sequence rendered
|
|
212
|
+
# a multi-gigabyte message (parsanol-ruby#190).
|
|
208
213
|
begin
|
|
209
|
-
walk(atom.parslet, mode == :exempt ? :exempt : false)
|
|
214
|
+
body = walk(atom.parslet, mode == :exempt ? :exempt : false)
|
|
215
|
+
if body.is_a?(Atoms::Lookahead)
|
|
216
|
+
# A whole-body lookahead keeps its #192 boundary visible
|
|
217
|
+
# to enclosing sequences (no wrapper before it).
|
|
218
|
+
body
|
|
219
|
+
else
|
|
220
|
+
ref = Atoms::Entity.new(atom.rule_name) { body }
|
|
221
|
+
ref.label = atom.label if atom.label
|
|
222
|
+
ref
|
|
223
|
+
end
|
|
210
224
|
rescue StandardError
|
|
211
225
|
atom
|
|
212
226
|
end
|
data/lib/parsanol/version.rb
CHANGED