[csharp/v8-spec] Continued improvements in the C# grammar.#4832
Draft
kaby76 wants to merge 17 commits into
Draft
[csharp/v8-spec] Continued improvements in the C# grammar.#4832kaby76 wants to merge 17 commits into
kaby76 wants to merge 17 commits into
Conversation
…toring. Three rules — null_coalescing_expression, expression, and range_expression — had alternatives sharing a long common prefix (unary_expression or conditional_or_expression), forcing ANTLR4's SLL simulation to scan up to 30 tokens before resolving the decision. Left-factor each rule so the shared prefix is consumed unconditionally and only a single token of lookahead is needed for the optional suffix. Add design docs explaining the problem and fix for each rule. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… (decision 31)
Extend IsConstantPatternAhead() to return false when LT(1) is '(' and a
comma appears at parenthesis depth 1 — indicating a tuple-positional pattern
such as ("rock", "scissors") or (0, 0), which cannot be a compile-time
constant. Add IsPositionalPatternAhead() as its complement and gate the
positional_pattern alternative in the grammar with it, making alts 2 and 4
mutually exclusive. Add design/pattern_positional.md documenting the
ambiguity and the fix.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
… to all targets Apply the same tuple-comma check and IsPositionalPatternAhead complement to all remaining language targets: Antlr4ng, Cpp (header + impl), Dart, Go, Java, JavaScript, Python3, and TypeScript. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ional_expression, doc cleanup
- All targets: fix IsConstantPatternAhead() to detect type-headed positional
patterns like Point(0,0) where LT(1) is an identifier, not '('.
C#/Java/Python3/Cpp use speculative type_() parse; Antlr4ng/TS/JS/Go/Dart
use LT(1)==identifier && LT(2)=='(' heuristic.
- CSharpParser.g4: rewrite conditional_expression to use explicit '?'
optional instead of the empty-alt form.
- design/primary_expression_mlr.md: fix stray backslashes in code blocks
(change '\' to '//' to match commenting style).
- design/pattern_positional.md: correct last table row — alt 2 is false
(speculative type_() + '(' suppresses it), alt 4 is true.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… before left-factoring Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ax-k 16→14 Left-factor field/method/property/indexer declarations in class_member_declaration, struct_member_declaration, and interface_member_declaration into a shared typed_member_declaration rule. Consuming the common attributes/modifiers/type_ prefix once forces immediate SLL→LL fallback for the ambiguous identifier-led alternatives, dropping max-k from 16 to 14 and parse time ~3×. Also add IsPrimaryConstraintAhead() / IsSecondaryConstraintAhead() predicates and fix BeginVariableDeclaration() to fall back to the parent context (typed_member_declaration) when the current context has no children yet. Both fixes applied to all nine target ports: CSharp, Java, Python3, Go, TypeScript, Antlr4ng, JavaScript, Cpp, Dart. Add design/typed_member_declaration.md documenting the root cause, failed sub-rule grouping approach, and the left-factoring solution. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Contributor
Author
|
The ECMA 334 Committee is currently working on the spec. Waiting for it to stabilize. |
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.
No description provided.