Skip to content

Tokens and locations

token_kind controls how the lexer exposes a token:

token_kindnext_tokeneach_token
:array[type, value]Yields one array
:structFlexr::Runtime::TokenYields a token
:yieldAdapter-definedYields type, value

Locations use byte offsets for the input position and track line/column as the lexer consumes text. Keep the location with the token when a parser needs useful syntax errors.

In v2, structured tokens and locations are immutable Data records. Read fields with attribute readers or [], and use with to create a replacement.

For exact defaults and the Location data structure, use the repository’s tokens and locations reference.