Skip to content
Beskid Platform specification

Beskid

Jump to a Beskid service

Beskid

Jump to a Beskid service

Grammar and parser contract - Design model

Platform spec article

Grammar and parser contract - Design model

Spec standingStandard

Owner
Piotr Mikstacki
Submitter
Piotr Mikstacki

This article documents design model for grammar and parser contract in the reference compiler.

  • compiler/crates/beskid_analysis/src/beskid.pest defines grammar tokens and precedence.
  • compiler/crates/beskid_analysis/src/syntax/ builds syntax items from parser output.
  • compiler/crates/beskid_analysis/src/syntax/items/parse_helpers.rs contains shared parse helpers.

The reference compiler must not define a language-level meta item grammar. Compiler mods use ordinary Beskid source plus SDK contracts (Collector, Generator, Analyzer, Rewriter).

Legacy MetaDefinition productions must be removed from beskid.pest and AST/HIR surfaces.

The grammar must define extend type as the normative type-extension syntax (see extend type). Generators emit extend type blocks as typed AST contributions.

Implementation must pair pest rules with item parsers under compiler/crates/beskid_analysis/src/syntax/items/ and snapshot tests under compiler/crates/beskid_tests.

The grammar must define:

ProductionRole
MacroDefinitionVisibility? macro Identifier ( MacroParameterList ) Block — module InnerItem.
MacroParameterMacroFragmentKind Identifier (closed kind keywords).
MacroInvocationIdentifier ! optional ( MacroArgumentList ) optional braced Blockexpression position.
MacroMetavariableExpr$ Identifier — legal only inside MacroDefinition bodies.

See Language macros. Expansion is host-driven in macro.expand; the parser only materializes definitions and invocation sites.

  • Treat diagnostics and tests as part of the contract, not optional implementation details.
  • When grammar changes, update this article and conformance tests in the same change.