How to add a keyword
Adding a keyword is a language change and therefore needs an ADR first (ADR 0006 is the current keyword set, amended by ADR 0017 for the exception keywords). Once the decision is made, the mechanical steps are:
- Add the variant to
lexer::token::Keywordand its entries in bothfrom_identandas_str. Update the "N reserved words" counts in the module docs. - Handle it in the parser: a dispatch arm in
parse_statement(or the expression parser), aparse_*method, and — if it starts a statement — an entry insynchronize's recovery set. - Add an
ExprKind/StmtKindvariant inast.rsand adump_*arm. - Visit the new node in
resolver.rsand execute it ininterpreter::exec_stmt/eval. If it adds aSignalvariant, the compiler will point out every match that must handle it. - Update the grammar and prose in
docs/spec/02-grammar.md, the relevant otherdocs/spec/section, the guide, and the keyword list indocs/spec/01-lexical-structure.mdanddocs/guide/README.md. - Amend ADR 0006 (or supersede it), and write the feature's own ADR.
- Tests: lexer test, parser tests (success + the malformed-syntax error),
resolver test, interpreter tests, a golden program under
crates/korrin/tests/programs/, thekorrin_ish()property generator, and aCHANGELOG.mdentry.