sigildocs

(sigil format tokenize)

(sigil format tokenize) - Positioned Sigil tokenizer (io-free)

The positioned tokenizer extracted from (sigil format) so downstream consumers (e.g. Slate's Tier-B syntax highlighting, compiled to WASM) can import JUST the tokenizer without pulling in the formatter or its dependencies (sigil-json, io/ports/fs).

This library is deliberately io-free: it depends only on (sigil core). tokenize takes a source string + filename and returns a (cons chars tokens) result; a token is a raw 6-slot vector.

Example: (let* ((r (tokenize "(+ 1 2)" "test.sgl")) (chars (tokenize-result-chars r)) (toks (tokenize-result-tokens r))) (token-type (car toks)) ; => lparen (token-value (car toks) chars)) ; => "("

Exports

token?procedure

Check if value is a token

token-typeprocedure

Token type accessor

token-startprocedure

Token start position accessor

token-endprocedure

Token end position accessor

token-lineprocedure

Token line accessor

token-columnprocedure

Token column accessor

token-indentprocedure

Token indent accessor

token-valueprocedure

Extract the text value of a token from the source chars vector

Get the chars vector from a tokenize result

Get the token list from a tokenize result

char-digit?procedure

Check if character is a digit

delimiter?procedure

Check if character is a delimiter

Check if string looks like a number

tokenizeprocedure

Tokenize entire source into a list of tokens Returns (cons chars tokens) where chars is the source as a vector