fix: plain parallel blocks take the replace-tree's duplicate semantics - #17
Merged
Merged
Conversation
Measured against Ruby: an all-plain parallel block compiles to a replace tree where a later duplicate from overwrites an earlier one — masm-mon lists sub "i" "й" ... sub "i" "и" precisely so the last wins. A block containing guards, or any rule whose from or result holds a boundary-like token (Ruby: "Can't use boundary in a par context"), falls back to the megaregexp, where the earliest equal-key rule wins — bgnpcgn-bal's و -> o, not the later w. The engine now drops every duplicate plain pattern except the last when the block is par-safe, and keeps index order otherwise. Direct corpus sweep: 46 failures / 14 maps -> 35 / 13 — masm-mon (11) fully healed, bal restored.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Two selection regimes, both measured against Ruby:
fromoverwrites an earlier one — masm-mon listssub "i" "й"…sub "i" "и"precisely so the last wins (measured with a synthetic duplicate map:i → и,ab → Y).The engine now drops every duplicate plain pattern except the last when the block is par-safe (
expr_is_par_safe), and keeps index order otherwise.Direct corpus sweep: 46 failures / 14 maps → 35 / 13 — masm-mon (11 examples) fully healed, bal restored. Suite 46 passed / 1 xpassed.