[new grammar] csharp v8-spec (ECMA-334 8th edition)#4789
Draft
kaby76 wants to merge 6 commits intoantlr:masterfrom
Draft
[new grammar] csharp v8-spec (ECMA-334 8th edition)#4789kaby76 wants to merge 6 commits intoantlr:masterfrom
kaby76 wants to merge 6 commits intoantlr:masterfrom
Conversation
Contributor
kaby76
commented
Mar 13, 2026
- Add CSharp v8-spec grammar targeting ECMA-334 8th edition (C# 8.0)
- Convert grammars to target-agnostic format: all inline actions replaced with this.PascalCase() calls; implementations in CSharpLexerBase.cs and CSharpParserBase.cs under CSharp/
- Add superClass options in both .g4 files; remove empty support .g4 imports
- Port v7 preprocessor approach: DIRECTIVE channel, DIRECTIVE_MODE, NextToken() override, SkipFalseBlock(), recursive-descent evaluator, --DSYM CLI support
- Restore parse tree nodes elided by mutual-left-recursion removal via As*() reflection-based methods in CSharpParserBase
- Add using_declaration to declaration_statement (C# 8 non-block using var)
- Add MS extension expressions: __makeref, __reftype, __refvalue
- Add 11 C# 8 example test files (CSharp8*.cs) covering switch expressions, tuple/positional patterns, readonly members, default interface members, using declarations, static local functions, nullable reference types, async streams, indices and ranges, ??= operator, and misc features
- Add test-dotnet.sh for C# 8 (LangVersion=8.0, Nullable=enable)
- Fix AllInOneNoPreprocessor.cs: invalid expression statements (i << 5) replaced with assignments; invalid ref-returning expression body fixed
- Add CSharp v8-spec grammar targeting ECMA-334 8th edition (C# 8.0) - Convert grammars to target-agnostic format: all inline actions replaced with this.PascalCase() calls; implementations in CSharpLexerBase.cs and CSharpParserBase.cs under CSharp/ - Add superClass options in both .g4 files; remove empty support .g4 imports - Port v7 preprocessor approach: DIRECTIVE channel, DIRECTIVE_MODE, NextToken() override, SkipFalseBlock(), recursive-descent evaluator, --DSYM CLI support - Restore parse tree nodes elided by mutual-left-recursion removal via As*() reflection-based methods in CSharpParserBase - Add using_declaration to declaration_statement (C# 8 non-block using var) - Add MS extension expressions: __makeref, __reftype, __refvalue - Add 11 C# 8 example test files (CSharp8*.cs) covering switch expressions, tuple/positional patterns, readonly members, default interface members, using declarations, static local functions, nullable reference types, async streams, indices and ranges, ??= operator, and misc features - Add test-dotnet.sh for C# 8 (LangVersion=8.0, Nullable=enable) - Fix AllInOneNoPreprocessor.cs: invalid expression statements (i << 5) replaced with assignments; invalid ref-returning expression body fixed Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
CSharpParser.g4: make stackalloc_initializer_element_list optional so
that 'stackalloc T[] {}' (zero-length) parses correctly. This form is
valid C# 7.3+ and accepted by Roslyn but was rejected by the grammar.
Also adds testing/test.sh which clones Roslyn at version-2.8.2, extracts
C# source snippets from tests tagged LangVersion.CSharp7_3, and verifies
each one parses cleanly with the ANTLR grammar.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.