Skip to content

fix: correct TextMate grammar badly highlighting lemire.gr - #186

Open
Kara-Zor-El wants to merge 1 commit into
grain-lang:mainfrom
Kara-Zor-El:Kara-Zor-El/lemire-syntax-highlighting
Open

Kara-Zor-El wants to merge 1 commit into
grain-lang:mainfrom
Kara-Zor-El:Kara-Zor-El/lemire-syntax-highlighting

Conversation

@Kara-Zor-El

@Kara-Zor-El Kara-Zor-El commented Sep 11, 2026 •

Copy link
Copy Markdown
Member

Issue Breakdown

The syntax highlighting seems to get messed up because our textmate grammar specifies blocks as anything appearing after =>, ) or an else. and records as any other combination of { <body> }. When we use an inline block like let x = { 1 } in lemire.gr it gets treated as a record and because there was a use WasmI32.{ (+), (-) } statement inside a match block which gets incorrectly parsed closing the parent record causing the highlighting for the rest of the file to be off.

Fix

The fix I implemented for this was to allow expressions to occur in records for the sake of syntax highlighting as it was a quick way of fixing the problem with no major downsides.

Correct Fix

We should revisit this in the future, and probably make a broader construct for { <body> } which can either contain a record disambiguated by weather the first thing inside is a field or record spread, or an expression.

Alternatively a simpler approach less correct to our grain grammar but correct enough for textmate would be to just make everything blocks and allow both record spreads and record fields in blocks. While this wouldn't be correct we don't exactly highlight records as a whole so it shouldn't be noticeable to users.

closes: #152

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.

Syntax Highlighting is bad in lemire.gr

1 participant