Skip to main content

Module token_class

Module token_class 

Source
Expand description

How LOGOS tokens are classified for highlighting: parts of speech are the syntax — verbs paint as functions, nouns as types, adjectives as modifiers. Every highlighting surface (LSP semantic tokens, the terminal REPL, any future renderer) derives its colors from this mapping, so they can never disagree.

The match is deliberately wildcard-free: adding a TokenType variant does not compile until someone decides its class — the decision lives here, next to the enum, not in an editor plugin.

Enums§

TokenClass
What a token IS, presentation-wise. Mirrors the LSP semantic-token vocabulary (the LSP legend maps 1:1; the REPL maps to ANSI colors).

Functions§

classify
Classify a token by its part of speech. None = a token no surface paints as ONE token: the structural ones (indent/dedent/newline/EOF), and an LGX raw section, whose body is painted by the language it is written in.
is_imperative_keyword
Is this token a statement word of imperative LOGOS — Let, Otherwise, Give, Send, … — as opposed to the English function words (a, is, of) that also class as keywords? An ambiguous token answers by its primary reading, as classify does.