public class Token extends Object
Represents a materialized lexical token with its text and source coordinates.
Unlike TokenSpan (which is optimized for zero-allocation line rendering), Token carries its sliced text, zero-based line and column numbers, and document character offsets for full-document analysis, refactoring, and parsing.
import klyn.code tok = Token(TokenKind.KEYWORD, "class", 0, 0, 0, 5) assert tok.text == "class" assert tok.kind == TokenKind.KEYWORD
| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | columncolumn as Long |
Zero-based column number where the token starts. |
| public readonly property | endOffsetendOffset as Long |
Zero-based exclusive end offset in the full source text. |
| public readonly property | kindkind as TokenKind |
Lexical classification of the token. |
| public readonly property | lineline as Long |
Zero-based line number where the token starts. |
| public readonly property | startOffsetstartOffset as Long |
Zero-based inclusive start offset in the full source text. |
| public readonly property | texttext as String |
Exact source substring of the token. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | Token | Constructs a materialized Token. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | isCommentisComment() as Boolean |
Returns true when this token is a comment (COMMENT or DOC_COMMENT). |
| public | isLiteralisLiteral() as Boolean |
Returns true when this token is a literal. |
| public | isTriviaisTrivia() as Boolean |
Returns true when this token is whitespace or a comment. |
| public override | toStringtoString() as String |
Formats this token for debugging. |