0%

§01 Lexer — capset keyword

Goal

Add capset to the lexer keyword table and emit TokenKind::Capset so the parser can dispatch on it.

Implementation Sketch

The lexer keyword table at compiler_repo/compiler/ori_lexer/src/keywords/mod.rs is a static match — adding capset is a one-line entry alongside siblings like extern, extension, def. The corresponding TokenKind::Capset variant is added to compiler_repo/compiler/ori_ir/src/token/kind.rs with the same derives as adjacent variants (Debug, Clone, Eq, PartialEq, Hash, serde — match the pattern of Extern / Extension / Def since they share the same declaration-keyword shape).

capset is reserved-but-reusable: it joins the small set of always-lexed-as-keyword tokens that the parser may also accept in identifier positions via cursor’s soft_keyword_str() (compiler_repo/compiler/ori_parse/src/cursor/identifiers.rs) IF the proposal allows that. Per the proposal §Design, capset is a strict module-level declaration keyword — NOT permitted in identifier positions. So no reuse via soft_keyword_str(); this is a hard reservation.

Implementation Items

  • Add "capset" => Some(TokenKind::Capset) to the keyword table in compiler_repo/compiler/ori_lexer/src/keywords/mod.rs (alphabetical position; sibling reference: extern, extension).
  • Add Capset variant to TokenKind enum in compiler_repo/compiler/ori_ir/src/token/kind.rs. Match the derives + ordering convention of adjacent declaration-keyword variants (Extern, Extension, Def).
  • Update any exhaustive-match consumers of TokenKind. Run cargo c after adding the variant; the compiler enumerates missing arms.
  • Verify reservation does not break existing programs: cargo t -p ori_lexer (lexer crate tests) AND ./test-all.sh (full corpus) green.
  • Rust Tests: compiler_repo/compiler/ori_lexer/src/keywords/tests.rs (or sibling) — assert capset lexes as TokenKind::Capset, NOT TokenKind::Ident.

Spec References

  • Proposal: compiler_repo/docs/ori_lang/proposals/approved/capset-proposal.md §Design + §Declaration.
  • Spec: compiler_repo/docs/ori_lang/v2026/spec/20-capabilities.md §20.11.
  • Grammar: compiler_repo/docs/ori_lang/v2026/spec/grammar.ebnf line 281 (capset_decl = "capset" identifier "=" identifier { "," identifier } ";" .).

Tests

Unit tests live in the lexer crate (sibling tests.rs); the spec test surface is owned by §05.

Intelligence Reconnaissance

Before implementation, run scripts/intel-query.sh callers TokenKind::Capset --repo ori (will return zero callers pre-implementation; rerun after to verify dispatch sites). Cross-language: scripts/intel-query.sh similar "alias_decl" --repo koka,rust,swift --limit 5 for prior-art patterns on transparent type/effect aliases.