Formally specify the @ extension annotations in ABNF output #2

Open
opened 2026-08-07 14:24:37 +00:00 by hum3 · 1 comment
Owner

Problem

tree-sitter2abnf emits ABNF with non-standard @ annotations (@token, @pattern, @prec, @field, @grammar, @extras) to represent tree-sitter concepts that have no ABNF equivalent.

These extensions are documented narratively in plain-text-accounting-formats/docs/abnf-variants.md, but they lack a formal grammar definition.

Why this matters

The development loop is: tree-sitter grammar → tree-sitter2abnf → ABNF text → tree-sitter ABNF parser → syntax highlighting. Currently the generated ABNF cannot be parsed by the tree-sitter ABNF grammar because the @ extensions are not part of the grammar. This breaks the feedback loop — highlighting silently produces nothing, and broken output goes unnoticed.

Without a formal spec, no parser (tree-sitter or otherwise) can be built to handle the extended syntax.

Requested

  1. Define the @ extension syntax formally (as ABNF rules or similar) — what is legal, how annotations nest, where they can appear
  2. Include the spec in this repo (e.g. docs/extensions.abnf or in the README)
  3. This spec then becomes the reference for extending the tree-sitter ABNF grammar (see hum3/gotreesitter issue)

Migrated from Codeberg: originally #2, opened 2026-03-18.

## Problem tree-sitter2abnf emits ABNF with non-standard `@` annotations (`@token`, `@pattern`, `@prec`, `@field`, `@grammar`, `@extras`) to represent tree-sitter concepts that have no ABNF equivalent. These extensions are documented narratively in [plain-text-accounting-formats/docs/abnf-variants.md](https://codeberg.org/hum3/plain-text-accounting-formats/src/branch/main/docs/abnf-variants.md), but they lack a formal grammar definition. ## Why this matters The development loop is: tree-sitter grammar → tree-sitter2abnf → ABNF text → tree-sitter ABNF parser → syntax highlighting. Currently the generated ABNF cannot be parsed by the tree-sitter ABNF grammar because the `@` extensions are not part of the grammar. This breaks the feedback loop — highlighting silently produces nothing, and broken output goes unnoticed. Without a formal spec, no parser (tree-sitter or otherwise) can be built to handle the extended syntax. ## Requested 1. Define the `@` extension syntax formally (as ABNF rules or similar) — what is legal, how annotations nest, where they can appear 2. Include the spec in this repo (e.g. `docs/extensions.abnf` or in the README) 3. This spec then becomes the reference for extending the tree-sitter ABNF grammar (see hum3/gotreesitter issue) --- *Migrated from Codeberg: originally [#2](https://codeberg.org/hum3/tree-sitter2abnf/issues/2), opened 2026-03-18.*
Author
Owner

The formal specification of @ extensions is moving to a dedicated repo: hum3/yabnf.

Audit completed: all 16 extensions (7 grammar-level directives, 9 rule-level annotations) confirmed load-bearing against real tree-sitter grammars (json, javascript). No redundant extensions found.

Gap identified: tree-sitter's top-level precedences key has no @ directive yet — to be addressed in the YABNF spec.

The formal spec is tracked in yabnf#1. This issue becomes "adopt YABNF as optional output format" once the spec is ready.

Keeping open, blocked on yabnf spec.

(hum3, 2026-03-18)

The formal specification of `@` extensions is moving to a dedicated repo: [hum3/yabnf](https://codeberg.org/hum3/yabnf). **Audit completed**: all 16 extensions (7 grammar-level directives, 9 rule-level annotations) confirmed load-bearing against real tree-sitter grammars (json, javascript). No redundant extensions found. **Gap identified**: tree-sitter's top-level `precedences` key has no `@` directive yet — to be addressed in the YABNF spec. The formal spec is tracked in [yabnf#1](https://codeberg.org/hum3/yabnf/issues/1). This issue becomes "adopt YABNF as optional output format" once the spec is ready. Keeping open, blocked on yabnf spec. *(hum3, 2026-03-18)*
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
hum3/tree-sitter2abnf#2
No description provided.