Expand description
Lexer for kaish source code.
Converts source text into a stream of tokens using the logos lexer generator. The lexer is designed to be unambiguous: every valid input produces exactly one token sequence, and invalid input produces clear errors.
§Token Categories
- Keywords:
set,tool,if,then,else,fi,for,in,do,done - Literals: strings, integers, floats, booleans (
true/false) - Operators:
=,|,&,>,>>,<,2>,&>,&&,|| - Punctuation:
;,:,,,.,{,},[,] - Variable references:
${...}with nested path access - Identifiers: command names, variable names, parameter names
Structs§
- Here
DocData - Tokens produced by the kaish lexer.
- Spanned
- A token with its span in the source text.
Enums§
- Lexer
Error - Lexer error types.
- Token
- Token
Category - Semantic category for syntax highlighting.
Functions§
- parse_
float - Parse a float literal.
- parse_
int - Parse an integer literal.
- parse_
string_ literal - Extract the string content from a string token (removes quotes, processes escapes).
- parse_
var_ ref - Parse a variable reference, extracting the path segments. Input: “${VAR.field[0].nested}” → [“VAR”, “field”, “[0]”, “nested”]
- tokenize
- Tokenize source code into a vector of spanned tokens.
- tokenize_
with_ comments - Tokenize source code, preserving comments.