public interface Tokenizer
Common contract implemented by all source code and markup tokenizers in klyn.code.
A Tokenizer supports both: 1. **Incremental line-by-line scanning** (tokenizeLine and nextLineState) for real-time syntax highlighting in terminal and GUI code editors without allocating substrings or rescanning the entire file. 2. **Full-document tokenization** (tokenize) producing materialized Token objects with line/column coordinates for parsers, refactoring tools, and metrics scanners.
import klyn.code
import klyn.code.klyn
tokenizer = KlynTokenizer()
result = tokenizer.tokenizeLine("public class Demo:")
assert result.spans.size > 0| Modifier and Type | Member | Description |
|---|---|---|
| public | isCodePositionisCodePosition(line as String, column as Long, initialState as LexicalState = null) as Boolean |
Checks whether the zero-based column in line is a code position (outside comments and string/character/regex literals). |
| public | nextLineStatenextLineState(line as String, initialState as LexicalState = null) as LexicalState |
Computes only the end-of-line LexicalState after scanning line from initialState, without allocating TokenSpan objects when possible. |
| public | profileprofile() as LanguageProfile |
Returns the declarative LanguageProfile associated with this tokenizer. |
| public | tokenize | Tokenizes a complete multi-line source document into materialized Token instances. |
| public | tokenizeLinetokenizeLine(line as String, initialState as LexicalState = null) as LineScanResult |
Tokenizes a single source line starting from initialState and returns the resulting TokenSpan list together with the end-of-line LexicalState. |