Skip to content

Conversation

@wherewhere
Copy link

@wherewhere wherewhere commented Oct 7, 2025

  • Primary constructors f28b268
  • field keyword in properties (I don't know how to make it only exist in properties) 8e6706d
  • allows ref struct constraint 7837d7a
  • Extensions f944628
  • Raw string literals (I don't know how to do it)
  • Collection Expressions (Conflict with InitializerTarget)

@macroscopeapp
Copy link

macroscopeapp bot commented Oct 7, 2025

Expand C# grammar to support extension blocks, updated generic constraints including 'allows' and nullable markers, additional preprocessor directives, 'field' expressions, and string 'U8'/'u8' suffixes in syntax.grammar

This pull request updates the C# grammar and development tooling. It adds new language constructs and constraints to the grammar, introduces extension blocks with members, and updates build/watch dependencies and configuration. Non-functional changes include formatting updates to development files and tokenizers.

  • Add extension block declarations with member support and constraints in syntax.grammar
  • Expand generic constraint parsing to include allows clauses, ref struct, optional ? on class/struct, default constraints, and comma-separated constraints in syntax.grammar
  • Add new preprocessor directives load, nullable, reference (r), and custom identifiers in syntax.grammar
  • Add field expressions and include them in primary expressions; allow U8/u8 suffix on regular and verbatim strings in syntax.grammar
  • Update class/struct/interface/enum declarations to support parameter lists before base clauses and optional semicolon-only forms; allow constructor-like arguments for first base type in syntax.grammar
  • Configure the dev CodeMirror editor to use a four-space indentation unit in index.ts
  • Switch the dev watch script to @marijn/buildtool and pass buildhelper options in watch.cjs; update related dependencies in package.json
  • Apply formatting-only changes to index.html, print-lezer-tree.ts, and tokenizer files in tokens.ts

📍Where to Start

Start with the grammar changes in syntax.grammar, focusing on extensionBlockDecl, typeParamConstraintsClause, preprocessor directive rules, and updated declaration forms.


Macroscope summarized 24e00f4.

@PaperPrototype
Copy link

Syntax highlighting breaks down when using top level statements

repro using codemirror-lang-csharp@6.2.0: https://www.sharptoy.net/
top level statements in C#: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/program-structure/top-level-statements

@wherewhere
Copy link
Author

I try to add it, but it broke more...
3aec1cc

1 similar comment
@wherewhere
Copy link
Author

I try to add it, but it broke more...
3aec1cc

@PaperPrototype
Copy link

PaperPrototype commented Jan 6, 2026

Oof, hmm, maybe the grammer architecture needs a more complex ruleset. I wonder if claude code could take a crack at it...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants