Sibling articles under this feature previously restated requirements in inconsistent forms.
Grammar and parser contract - Design model
Platform spec article
Grammar and parser contract - Design model
Spec standingStandard
-
This feature hub owns normative MUST/SHOULD contract text for Grammar and parser contract.
Context
Decision
This feature hub owns normative MUST/SHOULD contract text. Sibling articles must not redefine hub requirements and should link here for authority.
Consequences
Contract changes start on the hub or in linked ADRs, then propagate to articles and implementation anchors.
Verification anchors
site/website/src/content/docs/platform-spec/compiler/front-end/grammar-and-parser-contract/index.mdxarticle bundle under the same feature directory.
-
Platform-spec text supersedes informal crate comments for Grammar and parser contract.
Context
Implementation crates accumulated informal notes that diverged from published contracts.
Decision
Normative platform-spec prose and ADRs under this feature supersede informal comments in implementation crates until explicitly migrated into spec text.
Consequences
Engineers file spec/ADR updates when behavior changes; crate comments are non-authoritative for conformance arguments.
Verification anchors
compiler/crates/beskid_analysis/src/beskid.pestcompiler/crates/beskid_analysis/src/syntax/compiler/crates/beskid_analysis/src/syntax/items/parse_helpers.rs
-
This feature hub defines the normative contract for **grammar and parser contract** and links newcomer-oriented referenc
Context
This feature hub defines the normative contract for grammar and parser contract and links newcomer-oriented reference articles.
Decision
The reference compiler must implement Grammar and parser contract as documented in this feature hub and its article bundle.
Consequences
Changes require hub/ADR updates and verification anchor extensions.
Verification anchors
compiler/crates/beskid_analysis/src/beskid.pestcompiler/crates/beskid_analysis/src/syntax/compiler/crates/beskid_analysis/src/syntax/items/parse_helpers.rs
- Grammar and parser contract - Contracts and edge cases States the normative guarantees and what happens at boundaries or failure edges.
- Grammar and parser contract - Design model Explains the persistent concepts, entities, and boundaries this feature relies on.
- Grammar and parser contract - Examples Gives concrete newcomer-friendly scenarios mapped to real compiler paths.
- Grammar and parser contract - FAQ and troubleshooting Answers common operator and contributor questions with practical next checks.
- Grammar and parser contract - Flow and algorithm Walks through runtime/order-of-operations behavior in the implementation.
- Grammar and parser contract - Verification and traceability Shows how the team proves this feature works and where evidence lives.
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
This article documents design model for grammar and parser contract in the reference compiler.
Anchored code paths
Section titled “Anchored code paths”compiler/crates/beskid_analysis/src/beskid.pestdefines 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.rscontains shared parse helpers.
Metaprogramming grammar (removed)
Section titled “Metaprogramming grammar (removed)”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.
extend type production (v0.2 target)
Section titled “extend type production (v0.2 target)”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.
Language macro productions (v0.2 target)
Section titled “Language macro productions (v0.2 target)”The grammar must define:
| Production | Role |
|---|---|
MacroDefinition | Visibility? macro Identifier ( MacroParameterList ) Block — module InnerItem. |
MacroParameter | MacroFragmentKind Identifier (closed kind keywords). |
MacroInvocation | Identifier ! optional ( MacroArgumentList ) optional braced Block — expression 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.
Practical notes
Section titled “Practical notes”- 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.