Expand description
Token-based syntax highlighting for the REPL input bar and output.
Lexes the input with the real rl lexer and maps each TokenType to a
ratatui [Style]. Gaps between token spans are emitted as unstyled raw spans
to preserve whitespace exactly. On lex failure the entire input is returned
as a single red span.
§Color scheme
| Token group | Color / modifier |
|---|---|
| Control flow | Cyan bold |
| Declarations | Cyan italic |
| Import keywords | Cyan dim |
| Type keywords | Light blue italic |
| Logical operators | Yellow bold |
| Number literals | Magenta |
| String literals | Yellow |
| Char literals | Light yellow |
| Bool literals | Magenta italic |
null | Dark gray italic |
| Comparison ops | Light cyan |
| Punctuation/braces | Dark gray |
| Identifiers | White |
Functions§
- highlight
- Lexes
inputand returns a vec of syntax-highlighted [Span]s. - token_
color 🔒 - Returns the ratatui [
Style] for a givenTokenType.