Skip to content

Fix TAG lexer rule to allow a parenthesized value suffix - #149

Open
lukiod wants to merge 1 commit into
google:mainfrom
lukiod:fix-tag-expression-parenthesized-values
Open

Fix TAG lexer rule to allow a parenthesized value suffix#149
lukiod wants to merge 1 commit into
google:mainfrom
lukiod:fix-tag-expression-parenthesized-values

Conversation

@lukiod

@lukiod lukiod commented Aug 18, 2026

Copy link
Copy Markdown

Fixes #72.

The TAG lexer rule ('@' ~[@ )]+) excluded ) entirely, so a tag literal ending in a parenthesized value (e.g. @id("<uuid>")) had its closing paren misread as the grouping R_PAREN token instead of part of the tag. That truncates the tag text by one character and leaves a stray ), so tagExpressionMatchesPickle never matches the tag against itself.

Fix: the base tag body now also excludes ( (forcing it into a new optional group instead of being silently absorbed), and an optional trailing ('(' ~[)]* ')')? segment captures a parenthesized value verbatim, including its closing paren, as part of the same TAG token. Existing grouping-paren expressions ((@tagA and @tagB), nested parens) are unaffected, since a bare ( not immediately following @tagName still tokenizes as L_PAREN as before.

Verification: reproduced the failure directly against the unpatched grammar first — confirmed it tokenizes @id("uuid") as TAG=@id("uuid" (missing the final )) plus a stray R_PAREN, so the match fails — then confirmed the fix resolves it and that the existing grouping-paren test cases are unaffected.

One disclosure: this repo's own mvn test -Ptest currently reports 0 tests run for GherkinTagFiltererTest (no junit-vintage-engine on the classpath for this JUnit4-style class) — a pre-existing gap unrelated to this change, so I verified the fix and the three new regression tests directly by compiling against the ANTLR-generated parser and running the exact same assertions standalone rather than through the (currently non-functional) Maven test target.

The TAG rule (@' ~[@ )]+) excluded ')' entirely, so a tag literal
ending in a parenthesized value (e.g. @id("<uuid>")) had its closing
paren misread as the grouping R_PAREN token instead of part of the
tag, truncating the tag text by one character and leaving a stray
')' that never matches the stored pickle tag.

Fix: the base tag body now also excludes '(' (forcing it into the new
optional group instead of being silently absorbed), and an optional
trailing ('(' ~[)]* ')')? segment captures a parenthesized value
verbatim, including its closing paren, as part of the same TAG token.

Verified: reproduced the original failure directly (confirmed the
unpatched grammar tokenizes @id("uuid") as TAG=@id("uuid" plus a
stray R_PAREN, so tagExpressionMatchesPickle never matches), then
confirmed the fix resolves it and that existing grouping-paren
expressions ((@taga and @TAGB), nested parens) are unaffected.

Note on test execution: this repo's own `mvn test -Ptest` currently
reports 0 tests run for this JUnit4-style class (no junit-vintage-engine
on the classpath), a pre-existing gap unrelated to this change. Verified
directly instead by compiling against the generated parser and running
the exact scenarios from the added tests standalone.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tags with ("<UUID>") aren't filterable

1 participant