Skip to content

Action context

Actions run in the lexer context. Common methods include:

APIUse
text / text_bytesizeMatched text and its byte length
emit(type, value = text)Return a token
skipConsume input without emitting a token
echoWrite the matched text to the configured output
lineno, line, byte_posCurrent position information
beginning_of_line?Check the start-of-line condition
state, push, pop, begin_stateManage lexer states
less(n) / moreAdjust or extend the current match
error!(message)Raise a lexer error with location context

Prefer small, deterministic actions. If an action needs parser state or external services, keep that dependency in an adapter around the lexer.