parsanol 1.3.104-aarch64-linux → 1.3.105-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: fc25b50085a250243ed7d5e94c9f028ffaa48ce55c6e4b5e72a037cb97a28e5d
4
- data.tar.gz: 06f110ab23f0c30e48131b740efabbb26d7be26a7960cc34c5a283754078af12
3
+ metadata.gz: 82bc03a0b23a9a8d7504a043a69dd3b4173924c644cd94a3261311d3a4723218
4
+ data.tar.gz: ff3498232d47c056f13cd1eecbc048cb2281b83b4ecda6bc775d19317906769d
5
5
  SHA512:
6
- metadata.gz: 6c585244b47add8ca85ce23cadf3df96338078f7bee1864c7790843c1e0af91eabb468d8c9c231c7bb881f082d2a01a98d2f90d5744810fe68919019e7e06c07
7
- data.tar.gz: d4feb4309d16fec54b1ee7ecc0c89e81ac10644869452bf7de2e9518aa479fce4e6fc90955aa3257ba47f97e4fc36c216e0248e6d1a85afecf68a4d856c38a8a
6
+ metadata.gz: 1de990af98a1415ae63ceaa6273172966022666518470b6d0759fb385df86db5aaa63bd5ef5e36463ba1329f08428bd36c11ee34638b5ed013851d0a82e6cc75
7
+ data.tar.gz: 22e439c393b64036d5b9151e7016edeae132948fca1812fb337a39d053fbf69eaacfed77603a8e96b29d03e36a3087408fd3e7c86cab41e42deddcfcf802609a
@@ -331,14 +331,33 @@ module Parsanol
331
331
  { root_name => flattened }
332
332
  end
333
333
 
334
+ # Recovery error wire — the rs engine's F7 shape (offset, line,
335
+ # column, expected at the deepest position, ranked distinct
336
+ # positions deepest-first), computed from the interpreter's cause
337
+ # tree. `message` rides along for consumers that surface the
338
+ # rendered text (lutaml-lml digs line/column from it).
339
+ # Parity with parsanol::portable::parser::MAX_RANKED_FAILURES.
340
+ MAX_RANKED_FAILURES = 8
341
+
334
342
  def recovery_error(err)
335
343
  cause = err.parse_failure_cause
336
- # The raised cause can sit shallower than the real failure (a
337
- # consume-all leftover reported at the partial run's end);
338
- # recovery annotations carry the DEEPEST position in the cause
339
- # tree — the same semantics as the rs engine's failure wire.
340
- { "offset" => cause && deepest_position(cause),
341
- "message" => err.message }
344
+ return { "offset" => nil, "message" => err.message } unless cause
345
+
346
+ ranks = collect_ranks(cause)
347
+ offset = ranks.keys.max
348
+ line, column = cause.source&.line_and_column(offset)
349
+ {
350
+ "offset" => offset,
351
+ "line" => line,
352
+ "column" => column,
353
+ # The deepest entry mirrors ranked's head — same as the rs
354
+ # wire, where failure_wire and ranked[0] agree.
355
+ "expected" => ranks[offset] || [],
356
+ "ranked" => ranks.sort_by { |pos, _| -pos }
357
+ .first(MAX_RANKED_FAILURES)
358
+ .map { |pos, labels| [pos, labels] },
359
+ "message" => err.message,
360
+ }
342
361
  end
343
362
 
344
363
  def deepest_position(cause)
@@ -351,6 +370,22 @@ module Parsanol
351
370
  max
352
371
  end
353
372
 
373
+ # Distinct failure positions with the labels expected at each —
374
+ # every cause node contributes its position and message; deeper
375
+ # duplicates of the same position merge. Capped like the rs wire
376
+ # (MAX_RANKED_FAILURES) at the reader, deepest first.
377
+ def collect_ranks(cause, into = {})
378
+ labels = into[cause.position] ||= []
379
+ text = cause.message.to_s
380
+ labels << text unless labels.include?(text)
381
+ Array(cause.children).each do |child|
382
+ next if child.nil?
383
+
384
+ collect_ranks(child, into)
385
+ end
386
+ into
387
+ end
388
+
354
389
  # Journaling re-parse — always on the Ruby engine (journaling
355
390
  # rides the interpreter's diagnostic reparse; the native engine
356
391
  # has no journal). Tree parity with the native engine is enforced
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Parsanol
4
- VERSION = "1.3.104"
4
+ VERSION = "1.3.105"
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.104
4
+ version: 1.3.105
5
5
  platform: aarch64-linux
6
6
  authors:
7
7
  - Ribose Inc.