public class KlynTokenizer extends CodeTokenizer
Specialized CodeTokenizer for Klyn source files (.kn, .wp).
Extends CodeTokenizer with support for:
query: / query ( KQL blocks tracked across lines via LexicalState.queryIndent/pattern/gimsuy) disambiguated from division operators -Formatted strings (f"...", fr"...", f"""...""") with nested {...} interpolationpublic myMethod(...) as ReturnType:)import klyn.code
import klyn.code.klyn
tokenizer = KlynTokenizer()
res = tokenizer.tokenizeLine("public compute(x as Int) as Int:")
assert res.spans.size >= 5| Modifier and Type | Member | Description |
|---|---|---|
| public | KlynTokenizer | Constructs a KlynTokenizer initialized with KlynLanguage.profile(). |
| Modifier and Type | Member | Description |
|---|---|---|
| public override | classifyIdentifier | Classifies an identifier in Klyn source code, adding recognition for Klyn method declarations (public compute(x as Int)) even when def is omitted. |
| public override | nextLineStatenextLineState(line as String, initialState as LexicalState = null) as LexicalState |
Advances the lexical state across line without allocating TokenSpan objects, preserving Klyn query: block indentation tracking. |
| public | scanRegexLiteralEnd | Checks whether a / at index in line can start a /pattern/flags regular expression literal rather than a division operator, and returns the exclusive end index of the regex literal (or -1 if it is not a regex literal). |
| public override | tokenizeLinetokenizeLine(line as String, initialState as LexicalState = null) as LineScanResult |
Tokenizes a single line of Klyn code with contextual KQL query: state and regex literal support. |