The default lexer context, composed of the Column and Line tracking fragments.
This is the most commonly used context and provides useful information for error reporting. The text field is inherited from LexerCtx.
position and line are immutable vals of a subtype of Int: Tracking.materialize finds each fragment's given Tracking and threads a fresh copy of this case class through the lexer rather than mutating a field in place. Read them as plain Ints (ctx.line, ctx.position).
Value parameters
line
the current line number (1-based)
position
the current column position within the line (1-based)
Structural fallback for the getter/setter refinement that ctx (see below) types itself with, so that ctx.field += 1 type-checks even when field is an immutable val. The lexer macro rewrites away every such structural access inside a rule before it is compiled, so in practice this is only a safety net; it should never be hit at runtime.
Structural fallback for the getter/setter refinement that ctx (see below) types itself with, so that ctx.field += 1 type-checks even when field is an immutable val. The lexer macro rewrites away every such structural access inside a rule before it is compiled, so in practice this is only a safety net; it should never be hit at runtime.
A read-only view of the text still remaining to be tokenized.
A read-only view of the text still remaining to be tokenized.
Exposed so a custom alpaca.internal.lexer.ErrorHandling instance can inspect the character(s) that failed to match any token rule, e.g. to build a diagnostic message such as unexpected '${ctx.remainingText.charAt(0)}'.