Repository navigation
Grammars declare their context parameters; JavaScript for-heads follow the specification's [In] rule - #212
Merged
Conversation
…in led; interpreter and JavaScript grammar
… printers and recovery on ctx equations and gated leds; suppress deleted
…er the template token's holeCtx; Python's primary resets in
…ft is a LeftHandSideExpression; mixfix re-bind sees a ctx operand; tree-sitter reads the context-free view
…in left verdicts; jsTarget reads a Pratt rule at a level from another rule; a field on a group names its reference
…ORRECTNESS rows; emit sizes re-recorded
…d (4 files agree now)
… [~In]; TS lists as on master; the arrow-body greedy captures hold; tree-sitter record moves
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.
What changes
For grammar authors: context parameters are now declared by the grammar and set where the specification sets them. A grammar lists its parameters with their values at the top level (
params: { yield: false, await: false, in: true }).ctx({ in: false }, …)sets or clears some of them for what it holds, andwhen('+in', …)makes a rule item, an operator or a reserved word depend on them. This replacesexclude,reservableNotand the four markersawaitCtx,yieldCtx,asyncGenCtx,resetCtx, which are removed. A grammar that used them must be rewritten (see docs/GRAMMAR.md, "Contexts").For users of the JavaScript parser: a
forhead now follows the specification's[In]rule exactly, in every generated parser.for (x => x in y;;);in")for (a ? b : c in d;;);for (a = b in c);for (a + b of c);for (`${a in b}`;;);inagain)TypeScript keeps what TypeScript's own parser accepts: it reads any expression before
inin aforhead.Results
Cost
inagain saves and restores one small value.checker.ts+0.69%), and 2.7% more on a synthetic stress file. The Go parser takes 0.3% to 0.4% fewer. The TypeScript-target parser is +0.1%.Known limits
for (!a in c)andfor (a++ in c)still parse in JavaScript. Their left side is a unary or update expression, which the specification does not allow there.🤖 Generated with Claude Code