Core-0normative target; implementation partial

Tokens, grammar, parsing, and syntax constraints.

Core-0 Lexical and Syntax Clauses

Status: normative

The complete productions are in core-0.ebnf. These clauses fix behavior that a grammar alone cannot express.

Lexical clauses

C0-LEX-001 — Source encoding. A generated source or interface is UTF-8. U+0000 is rejected. One UTF-8 BOM may occur before the first token and is not a token; a BOM elsewhere is rejected. Source spans use half-open UTF-8 byte offsets.

C0-LEX-002 — Token determinism. The lexer applies longest-token matching, does not depend on locale, and recognizes identifiers from the ASCII identifier grammar. Trivia cannot occur inside a token. Block comments do not nest.

C0-LEX-003 — Literal validity. A numeric separator must separate digits of the same literal component. Escapes are validated before AST construction. Integer literal magnitude is retained exactly until contextual type checking; the lexer must not overflow a host integer while scanning it.

C0-LEX-004 — Reserved words. Every word listed by keyword in the EBNF is reserved. In particular, result is contextual only through semantic checks: it remains a token and cannot be declared as an identifier.

Syntax clauses

C0-SYN-001 — Complete units. A .zl or .zli contains one module declaration followed by imports and declarations, then end-of-file. There are no partial modules, wildcard imports, top-level statements, or implicit declarations.

C0-SYN-002 — One spelling. The EBNF defines the only accepted spelling and precedence for Core-0 constructs. A frontend must not add aliases, optional punctuation, automatic semicolon insertion, alternate operator names, or implementation-specific extensions while claiming Core-0.

C0-SYN-003 — Deterministic recovery. A parser may recover after an error, but its chosen recovery boundary and expected token classes are structured diagnostic facts. Recovery cannot create checked semantics for the damaged construct.

C0-SYN-004 — Deferred domains. workflow, compute, state, and optimize declarations are recognized sufficiently to report ZL-DOMAIN-0001, then rejected. They are never interpreted as algorithm bodies.

C0-SYN-005 — Contract disambiguation. requires T { ... } is a structural generic requirement because an identifier follows requires; requires { ... } is a message precondition. Generic requirements precede preconditions, which precede ensures, which precedes effects. No parser lookahead based on type-checking is required.

C0-SYN-006 — Lossless and canonical forms. The concrete syntax retains all tokens and trivia for source mapping. The canonical AST drops irrelevant trivia, preserves evaluated order, and assigns no meaning from formatting.

Projected fromspec/editions/core-0/lexical-and-syntax.md