Conversation
`<p>Shipping & Handling</p>` is valid JSX (React renders the ampersand), but scan_jsx_text stopped at every `&` and the grammar only accepts a full character reference there, so a bare `&` was a parse error. The scanner now looks past an `&`: if what follows is the rest of an HTML character reference as html_character_reference defines it (`&`, `&tree-sitter#38;`, `&`), the text ends before it and the reference is its own token as before; otherwise the ampersand is text. Fixes tree-sitter#366 Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This branch has not been deployed
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.
<p>Shipping & Handling</p>is valid JSX (React renders the ampersand), but scan_jsx_text stopped at every&and the grammar only accepts a full character reference there, so a bare&was a parse error.The scanner now looks past an
&: if what follows is the rest of an HTML character reference as html_character_reference defines it (&,&,&), the text ends before it and the reference is its own token as before; otherwise the ampersand is text. The calls to mark_end are there to handle the lookahead, specifically so that text after a bare & is included in the token.I had Fable 5.1 write the code, but I've manually looked over it. It does not break any existing tests, and this is pretty straight forward for manually written parsers: it was just a need to lookahead one token before "putting the parsing machine in a different state". I'm opening a similar PR against typescript.
Fixes #366