Extend embedded ABNF grammar to parse tree-sitter2abnf @ annotations #4
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
The embedded tree-sitter ABNF grammar (from upstream tree-sitter-abnf) only handles standard RFC 5234/7405 ABNF. It cannot parse the
@extension annotations emitted by tree-sitter2abnf (@token,@pattern,@prec,@field,@grammar,@extras).This breaks the development feedback loop: grammar → tree-sitter2abnf → ABNF text → tree-sitter ABNF parser → syntax highlighting. The ABNF parser returns a fully-errored tree, so highlighting produces 0 ranges and the output renders as plain text.
Evidence
Simple standard ABNF like
foo = "bar"\nparses and highlights correctly.Requested
Extend the ABNF grammar to handle the
@annotations so that tree-sitter2abnf output parses and highlights correctly. The formal spec for the extension syntax is being defined in hum3/tree-sitter2abnf#2.This likely means forking or extending the upstream tree-sitter-abnf grammar and embedding the extended version.
Highlight query additions
Once the grammar handles the extensions, the highlight query in
abnf_register.gowill need entries for the new node types (e.g. annotation names as keywords, pattern strings as strings).Migrated from Codeberg: originally #4, opened 2026-03-18.