Skip to content

[patch] Fix EBNF grammar, TextMate grammar#343

Merged
seldridge merged 2 commits intomainfrom
dev/seldridge/textmate-grammar-updates
Feb 16, 2026
Merged

[patch] Fix EBNF grammar, TextMate grammar#343
seldridge merged 2 commits intomainfrom
dev/seldridge/textmate-grammar-updates

Conversation

@seldridge
Copy link
Copy Markdown
Member

Fix mistakes in the EBNF grammar related to layers and layerblocks.

Fix many, many issues with the TextMate grammar with AI assistance. I did not
inspect the TextMate grammar changes. I did look at the output in VSCode with
this grammar loaded and llvm/circt's test/Dialect/FIRRTL/parse-basic.fir now
actually parses correctly.

The EBNF grammar for layer declarations and layerblock statements
was incorrect and did not match the actual syntax used in examples
throughout the specification.

Layer declarations use 'bind' or 'inline' keywords, not arbitrary
strings. Layerblock statements do not use an 'of' keyword and do
not contain port declarations.

This updates the EBNF to match the actual syntax:
- decl_layer: 'layer' id ',' ('bind' | 'inline') ':'
- layerblock: 'layerblock' id ':'

AI-assisted-by: Augment (Claude Sonnet 4.5)
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
Add support for three legacy FIRRTL syntaxes that are no longer in
the specification but may still appear in older code:

1. Legacy connect: 'foo <= bar' (equivalent to 'connect foo, bar')
2. Legacy partial connect: 'foo <- bar' (no modern equivalent)
3. Legacy invalidate: 'foo is invalid' (equivalent to 'invalidate
   foo')

All three legacy operators are highlighted with the scope name
'keyword.operator.legacy.firrtl' to distinguish them from modern
syntax.

Additionally, fix several issues with layer and control flow
syntax highlighting:

- Fix 'enablelayer' on modules to support multiple occurrences
- Improve visibility of 'layer' and 'layerblock' keywords
- Fix 'else when' syntax to properly highlight expressions
- Update layer pattern to match 'bind'/'inline' conventions
- Simplify layerblock pattern to match actual syntax

AI-assisted-by: Augment (Claude Sonnet 4.5)
Signed-off-by: Schuyler Eldridge <schuyler.eldridge@sifive.com>
@seldridge seldridge merged commit 5757092 into main Feb 16, 2026
1 check passed
@seldridge seldridge deleted the dev/seldridge/textmate-grammar-updates branch February 16, 2026 01:35
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.

1 participant