03 — Language System

Grammar


Section Overview

What This Is

The Language System defines the formal grammar, syntax rules, primitive type system, and composition model of IDL source files.

Why It Exists

Design intent expressed in natural language cannot be parsed, validated, or transformed deterministically. IDL requires a formal language so intent is unambiguous and machine-verifiable.

How It Works

Source files are parsed against the BNF grammar into a versioned AST. Any construct not expressible in the grammar is a hard Parse error.

Conceptual Model
LLanguage SystemGrammar · Syntax rules · Primitive types · Composition model
defines parse contract for
01Parse phaseSource text → versioned AST
PARSE ERRAST
AST forwarded to
02–03Transform · EmitAST consumed for validation and artifact generation

The Language System is consumed exclusively during Parse. Grammar stability is guaranteed within a minor version.

The IDL grammar is specified in Backus-Naur Form (BNF) and defines the complete syntactic structure of IDL source files. The grammar is context-free and deterministic: for any valid IDL input, the parser produces exactly one parse tree. Ambiguity in the grammar is a specification defect and must be resolved via the RFC process before any grammar change is finalised.

Grammar as Normative Specification

The BNF grammar is normative. Any construct expressible in the grammar is syntactically valid. Any construct not expressible in the grammar is a hard Parse error. Prose descriptions of IDL syntax in this specification are informative explanations of the grammar, not independent normative sources. In cases of conflict, the BNF governs.

Grammar Versioning

The grammar is versioned alongside the specification. The grammar version is declared at the top of each IDL source file. The parser rejects source files that declare a grammar version incompatible with the compiler version in use. Grammar stability is guaranteed within a minor version: no construct valid under grammar vN.x becomes invalid under grammar vN.(x+1).

Core Grammar Productions

  • module — the top-level construct; each file declares exactly one.
  • import — declares cross-module dependencies; circular imports are a grammar-level error.
  • token — a named value declaration with type annotation.
  • component — a named component specification with prop, slot, state, and variant declarations.
  • constraint — an inline constraint declaration attached to a schema element.
  • pattern — a named multi-component composition schema.