parsanol 1.3.85-aarch64-linux → 1.3.86-aarch64-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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2fb094f721fc4cae062cf0516e8a210ac26bb9346ca4bd5ff39397218899372
4
- data.tar.gz: 16d4ec0c27c22efe0dd59ad081425bc2bd1dd7a6c3bb58411460e3feb5362bc4
3
+ metadata.gz: 7f606f2109b455b5172f2276e4153de88a4337df99e988ecc0457e31a454ac06
4
+ data.tar.gz: bd2fd2fea6eeac7df53ee9dece30979005d3b6a75eea1c65c4eefd5144c21339
5
5
  SHA512:
6
- metadata.gz: c72ae01c19db7e97fb61a5c787d4629d0ef439df72dfbbd021afbec09b0f70c8eb3e6010df1b84060cd18fe9247753157373f0576fc57476f4a982542f91c3b0
7
- data.tar.gz: '09cb081d4143380cc4fc11530fa31328ead71172f30714ec5f7e240c8055c2d9d7057d817d54ee09b4e7ce9019c38fb3730bda821f59b720f6b6e1bb44b640b8'
6
+ metadata.gz: 32ebdc3762b1e9295bfc706be3e1d3350ac9f43d25c7bd8810140a797a81f25a5ae513a229f01240b716fce6c5b00625b500090891560bef0fd42c2eb36ed219
7
+ data.tar.gz: 61afd97e9b96b975ed99f37df1ca479356361f5d1373bdb4e4b589fd0074de4532c98f3407f18dfa763a473c107909d40e36227caa2c6ea9d7b694b73aa789f0
@@ -235,7 +235,10 @@ module Parsanol
235
235
  kids = atom.parslets.map { |child| inject_skip_trivia(child) }
236
236
  out = []
237
237
  kids.each do |child|
238
- out << skip_maybe_atom unless skip_wrapper?(child)
238
+ # parsanol-ruby#192: no injected skip directly before a
239
+ # lookahead — its contract is the raw next character.
240
+ out << skip_maybe_atom unless skip_wrapper?(child) ||
241
+ child.is_a?(Atoms::Lookahead)
239
242
  out << child
240
243
  end
241
244
  out.length == 1 ? out.first : Atoms::Sequence.new(*out)
@@ -271,7 +274,11 @@ module Parsanol
271
274
  # `atomic` rules deliberately stop doing.
272
275
  Atoms::Named.new(inject_skip_trivia(atom.parslet), atom.name)
273
276
  when Atoms::Lookahead
274
- Atoms::Lookahead.new(inject_skip_trivia(atom.bound_parslet), atom.positive)
277
+ # parsanol-ruby#192: a lookahead's contract is the RAW text
278
+ # ahead — injected separators inside would make keyword
279
+ # boundary checks examine the wrong character. Interiors
280
+ # stay injection-exempt, not even rule references re-scope.
281
+ atom
275
282
  when Atoms::Str, Atoms::Re
276
283
  # bare terminal as a whole rule body: leading trivia position
277
284
  Atoms::Sequence.new(skip_maybe_atom, atom)
data/lib/parsanol/skip.rb CHANGED
@@ -109,9 +109,13 @@ module Parsanol
109
109
  @wrapper_ids = {}.compare_by_identity
110
110
  # Results keyed per injection context: the same shared atom
111
111
  # can be reached both inside and outside repetition interiors,
112
- # and the refinement injects differently there.
113
- @memo = { true => {}.compare_by_identity, false => {}.compare_by_identity }
114
- @in_progress = { true => {}.compare_by_identity, false => {}.compare_by_identity }
112
+ # and the refinement injects differently there. The :exempt
113
+ # context (lookahead interiors, ruby#192) suppresses injection
114
+ # everywhere, rule references included.
115
+ @memo = { true => {}.compare_by_identity, false => {}.compare_by_identity,
116
+ exempt: {}.compare_by_identity }
117
+ @in_progress = { true => {}.compare_by_identity, false => {}.compare_by_identity,
118
+ exempt: {}.compare_by_identity }
115
119
  end
116
120
 
117
121
  def inject(atom, entry: false)
@@ -149,27 +153,33 @@ module Parsanol
149
153
  # terminals inside a repetition consumes trivia within the
150
154
  # ENCLOSING capture's scope and mis-attaches recorded units when
151
155
  # the iteration fails.
152
- def walk(atom, rep_interior)
153
- cached = @memo[rep_interior][atom]
156
+ def walk(atom, mode)
157
+ cached = @memo[mode][atom]
154
158
  return cached if cached
155
- return atom if @in_progress[rep_interior].key?(atom)
159
+ return atom if @in_progress[mode].key?(atom)
156
160
  return atom if atom.equal?(@skip_atom)
157
161
 
158
- @in_progress[rep_interior][atom] = true
162
+ @in_progress[mode][atom] = true
159
163
  injected =
160
164
  case atom
161
165
  when Atoms::Sequence
162
166
  out = []
163
167
  atom.parslets.each do |child|
164
- walked = walk(child, rep_interior)
165
- unless rep_interior || wrapper?(walked) || walked.is_a?(Atoms::Trivia)
168
+ walked = walk(child, mode)
169
+ # parsanol-ruby#192: no wrapper directly before a
170
+ # lookahead — a lookahead's contract is the raw next
171
+ # character, and an injected separator between a
172
+ # keyword and its boundary check makes the check
173
+ # examine the wrong character.
174
+ unless mode || wrapper?(walked) || walked.is_a?(Atoms::Trivia) ||
175
+ walked.is_a?(Atoms::Lookahead)
166
176
  out << maybe
167
177
  end
168
178
  out << walked
169
179
  end
170
180
  out.length == 1 ? out.first : Atoms::Sequence.new(*out)
171
181
  when Atoms::Alternative
172
- Atoms::Alternative.new(*atom.alternatives.map { |a| walk(a, rep_interior) })
182
+ Atoms::Alternative.new(*atom.alternatives.map { |a| walk(a, mode) })
173
183
  when Atoms::Repetition
174
184
  if wrapper?(atom)
175
185
  atom
@@ -178,11 +188,16 @@ module Parsanol
178
188
  atom.result_tag)
179
189
  end
180
190
  when Atoms::Named
181
- Atoms::Named.new(walk(atom.parslet, rep_interior), atom.name)
191
+ Atoms::Named.new(walk(atom.parslet, mode), atom.name)
182
192
  when Atoms::Lookahead
183
- Atoms::Lookahead.new(walk(atom.bound_parslet, rep_interior), atom.positive)
193
+ # parsanol-ruby#192: a lookahead's contract is the RAW
194
+ # text ahead — no injection inside, rule references
195
+ # included (an injected separator between a keyword and
196
+ # its boundary check makes the check examine the wrong
197
+ # character).
198
+ Atoms::Lookahead.new(walk(atom.bound_parslet, :exempt), atom.positive)
184
199
  when Atoms::Ignored
185
- Atoms::Ignored.new(walk(atom.wrapped_atom, rep_interior))
200
+ Atoms::Ignored.new(walk(atom.wrapped_atom, mode))
186
201
  when Atoms::Entity
187
202
  # Rule bodies own their injection when the grammar declares
188
203
  # skip on every rule (PARG); in the DSL surface the root tree
@@ -191,17 +206,17 @@ module Parsanol
191
206
  # fresh injection scope even inside a repetition interior —
192
207
  # the d54a29e exception is for rule-reference children.
193
208
  begin
194
- walk(atom.parslet, false)
209
+ walk(atom.parslet, mode == :exempt ? :exempt : false)
195
210
  rescue StandardError
196
211
  atom
197
212
  end
198
213
  when Atoms::Str, Atoms::Re
199
- rep_interior ? atom : Atoms::Sequence.new(maybe, atom)
214
+ mode ? atom : Atoms::Sequence.new(maybe, atom)
200
215
  else
201
216
  atom
202
217
  end
203
- @in_progress[rep_interior].delete(atom)
204
- @memo[rep_interior][atom] = injected
218
+ @in_progress[mode].delete(atom)
219
+ @memo[mode][atom] = injected
205
220
  injected
206
221
  end
207
222
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.85"
4
+ VERSION = "1.3.86"
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.85
4
+ version: 1.3.86
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Ribose Inc.