Skip to main content

Module keywords

Module keywords 

Source
Expand description

The single source of truth for the language’s keywords.

Every keyword’s CAPS spelling lives exactly once, in kw. The KEYWORDS table attaches each one’s role (may it begin a statement?) and its syntax card (canonical form, one-line gloss, a copy-paste example). Everything else in the workspace that needs to know a keyword — the reserved-word check, recovery resync, the diagnostic cards, the parser’s tag(...) calls, and the compiler’s provenance kind strings — derives from this table or references a kw constant, so a keyword string is never written twice.

Modules§

kw
The CAPS spelling of every keyword — the one place each literal appears.

Structs§

Card
The correct-syntax reference for one keyword: its canonical written form (with <slots> and [optional] parts), a one-line plain meaning, and a real, valid example a model can copy. Mirrors docs/SPEC.md, “DSL: keywords”.
Keyword
One keyword: its spelling, whether it may begin a top-level statement, and its syntax card.

Constants§

KEYWORDS
Every keyword, in teaching order. The top-level statements come first (so filtering top_level yields the menu order), then IMPORT/AS, then the body and modifier words.

Functions§

card_for
The syntax card for keyword, or None if it is not a known keyword.
is_reserved
Whether word is a reserved keyword.
is_top_level
Whether word can begin a top-level statement (used by recovery resync).
keyword_in
The first keyword named anywhere in message (selects its card in a diagnostic). Splits on non-alphabetic characters and returns the first token that is a keyword.
top_level_forms
The keywords that may begin a top-level statement, in teaching order — shown as the menu when an error is not tied to one specific keyword.