fix: recipe calls starting with "open" or containing hyphens misparse (PT-23, PT-24)#174
Merged
Merged
Conversation
… (PT-23, PT-24)
PT-23: "open" is a reserved keyword for the built-in "open the
app"/"open link" verbs, and the parser claimed any step starting with
it unconditionally. A recipe literally named "open most recent post"
fell into open's undocumented bare-selector fallback, which consumed
just the next word as a selector and left the rest of the line to
misparse as a second, stray, unknown recipe call.
Fixed by only treating "open" as the built-in verb when what follows
actually matches one of its two documented forms ("the app"/"app", or
a link) via a backtracking lookahead (looksLikeOpenVerb); anything
else now falls through to a normal recipe call, preserving the whole
phrase as the call's name.
PT-24: the lexer tokenized a word-internal hyphen as its own
standalone token unconditionally - fine for a recipe *definition*
(name comes from a quoted string, hyphen preserved as-is), but at the
*call* site the name is built by rejoining bare word tokens with
spaces, so the hyphen came back out padded ("looking - for"), and the
two representations could never match for any hyphenated recipe name.
Fixed by keeping a hyphen directly between two word characters part
of the same identifier token. A standalone hyphen (the negative sign
in "set location -33.8, 151.2") is unaffected - it's only reached
preceded by a space, never mid-identifier, so this lexer path never
sees it.
Both confirmed via new parser tests (checked to fail against the
pre-fix code, reproducing the exact reported error shapes) and
real-device verification against a running app.
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.
Summary
PT-23:
openis a reserved keyword for the built-inopen the app/open linkverbs, and the parser claimed any step starting with it unconditionally. A recipe literally namedopen most recent postfell intoopen's undocumented bare-selector fallback, which consumed just the next word as a selector and left the rest of the line to misparse as a second, stray, unknown recipe call.Fixed by only treating
openas the built-in verb when what follows actually matches one of its two documented forms (the app/app, or a link) via a backtracking lookahead; anything else now falls through to a normal recipe call, preserving the whole phrase as the call's name.PT-24: the lexer tokenized a word-internal hyphen as its own standalone token unconditionally -- fine for a recipe definition (name comes from a quoted string, hyphen preserved as-is), but at the call site the name is built by rejoining bare word tokens with spaces, so the hyphen came back out padded (
"looking - for"), and the two representations could never match for any hyphenated recipe name.Fixed by keeping a hyphen directly between two word characters part of the same identifier token. A standalone hyphen (the negative sign in
set location -33.8, 151.2) is unaffected -- it's only reached preceded by a space, never mid-identifier, so this lexer path never sees it.Test plan
go build ./...,go vet ./...,go test ./...all passstaticcheck ./...cleanTestParser_RecipeCallStartingWithOpen,TestParser_HyphenatedRecipeCall), plus a regression guard (TestParser_SetLocationNegativeCoordinates,TestParser_OpenLink) confirming the documented forms still work. Confirmed both new tests fail against the pre-fix code, reproducing the exact reported error shapes ({Verb:open ...} {Name:"recent post"...}and"create looking - for post <arg> <arg>").