Add the second pipeline stage: a hand-written recursive-descent parser with a
cascade expression layer, plus the AST it builds. Chosen over chumsky for precise
control of the specification's sync-point error recovery and plain-English errors;
the AST and later checkers are agnostic to this choice.
- legis-ast: full AST for declarations, statements, the precedence-encoded
expression grammar, match/when in statement and expression forms, attempt,
ranges, actions, tags, and conditional blocks. Spans on items, statements,
expressions, and types.
- legis-parser: parses the whole grammar (minus the web route DSL, deferred to
the web phase), with error recovery to synchronization points and a 20-error
cap. Generic-call vs comparison is disambiguated by a restoring trial parse of
`<Type,...>(`. Non-associative equality is rejected.
- legis-cli: new `parse` command dumping the syntax tree.
- Reference-program-over-grammar decisions, all exercised by the calculator:
match arms may test a direct value (`is "+"`); arm bodies may be `{ }` blocks;
a `when` expression arm may hold a bare `give back`; a `contract` may describe
a constructor.
- legis-lexer: add the `while` keyword; make `value` a plain identifier (the
reference program uses it as a name), with `has value` matched contextually.
27 tests pass (6 diag + 12 lexer + 9 parser); fmt and clippy clean. The reference
calculator parses to a correct AST with no problems.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Stand up the Cargo workspace for the Legis compiler and implement the lexer,
the first stage of the pipeline described in the v1.0 specification.
- legis-diag: Diagnostic type plus the banned-jargon guard that the whole
toolchain is tested against (no forbidden programming term may appear in any
message). Whole-word, underscore-aware matching so quoted code identifiers
are not false positives.
- legis-lexer: logos-based lexer covering the full token list. Numbers carry no
sign (unary minus is a parser concern), text and multi-line text values,
doc comments preserved while line/block comments are dropped, longest-match
tags and operators, plain-English lexer errors.
- legis-cli: the `legis` binary with a `tokens` inspection command.
- examples/calculator.lgi: the specification's reference program, the milestone
the pipeline is built toward.
- PLAN.md: phased implementation roadmap (LLVM-from-start).
18 tests pass; fmt and clippy clean. The lexer tokenizes the reference
calculator with no errors.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>