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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47aefbe702313d394398c0a3761f397d13f912521310b924bf84361bd336e920
4
- data.tar.gz: f575935f73c5244972ed7e3cd93c0c9b9ee4de775127587d85e3e36319202808
3
+ metadata.gz: a0b4e99564a7a93dc454c5e004acb05f2fb6884dc993a75c3eb30565c0360687
4
+ data.tar.gz: 64ce48196a227e8c4f73dbc1d16a5415a278ef8a7730aaa7c8e85b45b28e75b3
5
5
  SHA512:
6
- metadata.gz: 1c1d2274eb415f449ee1f93d5ccd09a1ba087504ff3e842bcbf7212f40dfeac61d6cc988a3c285559b82f48f59ddc7be20a2640743fff9de1b643e5517b8ae93
7
- data.tar.gz: 3730499554f40a734a38385a20e5a81bb836306ef87e19469409e7ca76fde72f311b33571e941a0cc3539be54c14f717fa86c470e742d7120c8124b799eafe1a
6
+ metadata.gz: 2fde0240109a63a418d2851ca9578293934c784a0e14c74ecf74032dab99c361c729fdb468c4a4c8fdbc39e0f836a00a04202ccc7cfc96485230adfe636c7772
7
+ data.tar.gz: 516e9a87cc5577b0f00d1f994783cb0da6132105052f466f3ed4afb45b41445d29234d96443c15e39b1557d14c93395457c10d9bc5b4a2d7d30ef8393dcc4ae1
@@ -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 = label || to_s_inner(precedence)
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 descend through resolved bodies with
205
- # the in-progress set guarding recursion. A rule body is a
206
- # fresh injection scope even inside a repetition interior —
207
- # the d54a29e exception is for rule-reference children.
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.86"
4
+ VERSION = "1.3.87"
5
5
  end
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.86
4
+ version: 1.3.87
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.