glisp / lex
lex
Classes
LexError
Defined in: lex.ts:492
Thrown by lex on an unrecoverable input (an unexpected character, a bad string escape, an unterminated string, etc.). Carries the full source text and the byte offset where lexing gave up so a host can render a positional error message.
Extends
Error
Constructors
Constructor
new LexError(
message,source,position):LexError
Defined in: lex.ts:493
Parameters
| Parameter | Type |
|---|---|
message | string |
source | string |
position | number |
Returns
Overrides
Error.constructor
Properties
| Property | Modifier | Type |
|---|---|---|
position | readonly | number |
source | readonly | string |
Interfaces
Token
Defined in: lex.ts:60
A single lexed token: its kind, the verbatim source slice (text), the half-open source offsets ([start, end)), and a decoded value for kinds that carry one (numbers, strings, booleans, unit, paths).
Properties
| Property | Modifier | Type |
|---|---|---|
end | readonly | number |
kind | readonly | TokenKind |
start | readonly | number |
text | readonly | string |
value? | readonly | string | number | boolean | typeof UNIT | readonly (string | number)[] |
Type Aliases
TokenKind
TokenKind =
"("|")"|"["|"]"|"{"|"}"|":"|"="|"=>"|"^"|"?"|"`"|"~"|"..."|"...~"|"."|"()"|"_"|"!"|"number"|"string"|"boolean"|"identifier"|"pathSegments"|"eof"
Defined in: lex.ts:27
Every kind of token the lexer emits. Punctuation kinds equal their source form (e.g. '(', ':', '=>'); the rest are descriptive names for variable-shape tokens ('number', 'identifier', …). The trailing 'eof' token is always present so consumers can peek past the end without bounds-checking.
Functions
lex()
lex(
src):Token[]
Defined in: lex.ts:78
Tokenize Glisp source into a flat token sequence. Whitespace and ;-style comments are skipped. The returned array always ends with an { kind: 'eof' } token. Throws LexError on the first unrecoverable character (bad escape, unterminated string, etc.).
Parameters
| Parameter | Type |
|---|---|
src | string |
Returns
Token[]