Parsing: The '!' Alias Only Holds When It Is Glued to Both Sides - #1010
Open
daveycodez wants to merge 3 commits into
Open
Parsing: The '!' Alias Only Holds When It Is Glued to Both Sides#1010daveycodez wants to merge 3 commits into
daveycodez wants to merge 3 commits into
Conversation
jbylund#971 made '!' an '=' alias on COLOR/MANA/NUMERIC/RARITY/YEAR/DATE, but both parsers applied it across whitespace, which Scryfall does not. Measured live on api.scryfall.com: c!w 5,071 the alias c !w 0 name-and-exact-name reading, not the alias c! w 2,061 not the alias either cmc!3 8,077 the alias cmc !3 0 cmc! 3 0 r!rare 11,770 the alias r !rare 0 So the alias requires the bang glued on BOTH sides. The hand parser now asks space_before of the bang and of the token after it, in the NUMERIC branch and the class-gated one; the pyparsing grammar spells the same rule as leave_whitespace() on the bang plus a (?=\S) lookahead. A spaced bang keeps exactly the exact-name-prefix reading a space always had — `c !w` parses as it did before jbylund#971, and `cmc !3` rejects as it did before jbylund#971. Seven parity cases pin it: both parsers agree on every spaced spelling, and none of them may produce the glued spelling's tree. Suite: api/parsing/tests 2,319 passed; ruff check and format clean.
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.
#971 made '!' an '=' alias on COLOR/MANA/NUMERIC/RARITY/YEAR/DATE, but both
parsers applied it across whitespace, which Scryfall does not. Measured live
on api.scryfall.com:
So the alias requires the bang glued on BOTH sides. The hand parser now asks
space_before of the bang and of the token after it, in the NUMERIC branch and
the class-gated one; the pyparsing grammar spells the same rule as
leave_whitespace() on the bang plus a (?=\S) lookahead. A spaced bang keeps
exactly the exact-name-prefix reading a space always had —
c !wparses asit did before #971, and
cmc !3rejects as it did before #971.Seven parity cases pin it: both parsers agree on every spaced spelling, and
none of them may produce the glued spelling's tree. Suite: api/parsing/tests
2,319 passed; ruff check and format clean.
(Found by review tooling on the Cloudflare port's sync of #971; the port carries the same fix so the two trees stay in step.)