Lexical and syntax
Platform spec node
Lexical and syntax
Spec standingStandard
No architecture decision records under adr/ for this feature yet. Standard features must
publish at least one ADR or keep a ## Decisions summary on the hub.
- Documentation comments Structured comments attach human-readable contracts to declarations. Tooling must preserve them through formatting and refactors without changing semantics.
- Lexical and syntax Defines tokens, whitespace, and the context-free skeleton that every later phase assumes. The normative grammar and lexical rules live in the Language Spec; this page records platform ownership and ho…
0 revisions (git unavailable at build; counts may be empty)
No commits recorded for this path.
| Section id | Required | Found |
|---|---|---|
scope | yes | yes |
features | yes | yes |
Full tree: run pnpm verify:platform-spec-layout (writes src/generated/platform-spec-layout-report.json).
Normative specification
Section titled “Normative specification”This chapter defines lexical structure and the context-free program skeleton for Beskid v0.1. The authoritative grammar is compiler/crates/beskid_analysis/src/beskid.pest; this page states language-law constraints implementations must share across parser, formatter, and LSP.
Lexical rules
Section titled “Lexical rules”- Whitespace (
, tab, CR, LF) is insignificant except as a separator; it must not appear inside tokens unless the grammar allows it. - Identifiers must match
Identifier: ASCII letter or_followed by alphanumeric/_characters, and must not spell a reserved Keyword (see grammarKeywordproduction). - Integer and float literals must follow the pest productions; there is no implicit radix or suffix form in v0.1.
- String literals support
"..."with escapes\",\\,\\${, and${ expression }interpolation. Interpolation expressions must be validExpressionsubtrees. - Char literals use single quotes with
\'escape. - Comments:
//line comments (not starting a third/) are ordinary comments.///on items begins a documentation run (see Documentation comments);////and longer slash runs are not documentation./* ... */block comments nest by terminator only (no nesting of/*).
Program structure
Section titled “Program structure”- A compilation unit is
Program = ItemListterminated by end of input. - Top-level items must be one of:
host,macro, function,impl,extend type,type,enum,contract,test,attribute, inlinemod,moddeclaration, oruse. - Keywords reserved for DI (
host,registry,scope,launch,inject, …) must be tokenized as keywords even when not yet used in a given compilation unit.
Static rules (syntax-only)
Section titled “Static rules (syntax-only)”- Generic parameter lists use angle brackets:
<T, U>. - Type syntax order of precedence:
ArrowFunctionTypebeforeFunctionTypebeforeref TbeforeT[]beforeTypeName. match,if/else,while,for … in,with, andlaunchstatements must parse asStatementproductions; malformed nesting is a parse error, not a semantic error.
Dynamic semantics
Section titled “Dynamic semantics”Lexical and syntactic validity does not imply semantic validity. Phases after parsing must reject programs that parse but violate module, type, or contract rules.
Diagnostics
Section titled “Diagnostics”Parse failures must surface as parser diagnostics (no stable E#### band in v0.1). Early structural issues discovered during HIR construction use E1151–E1154. See Diagnostic code registry.
Conformance
Section titled “Conformance”A tool claiming Beskid L0 conformance must accept the same token stream as beskid.pest for all inputs in the reference parser test corpus.
Decisions
Section titled “Decisions”- D-LM-LEX-001 — Pest as grammar source: The checked-in pest file is the single syntactic truth; prose here summarizes but does not fork the grammar.
- D-LM-LEX-002 —
///documentation: Triple-slash doc lines attach only viaItemWithDocs; four-or-more slashes are never doc comments. - D-LM-LEX-003 — Reserved async/await: Tokens exist in the grammar for forward compatibility; semantic use is forbidden in Fibers and spawn (compile error if used as expressions).
Platform view
Section titled “Platform view”Defines tokens, whitespace, and the context-free skeleton that every later phase assumes. Formatter and LSP must preserve token boundaries defined here.