public static appendLiteralSpans( spans as ArrayList<TokenSpan>, line as String, start as Long, end as Long, highlightEscapes as Boolean, tokenKind as TokenKind = TokenKind.STRING ) as Void
Emits string content and escape spans (TokenKind.STRING and TokenKind.STRING_ESCAPE) for the literal segment line[start:end].
| Parameter | Description |
|---|---|
spans | Destination list of TokenSpans. |
line | Source line text. |
start | Inclusive start index of the literal segment. |
end | Exclusive end index of the literal segment. |
highlightEscapes | true to split valid backslash escape sequences into STRING_ESCAPE spans. |
tokenKind | Base token kind (TokenKind.STRING or TokenKind.CHARACTER). |
import klyn.code spans = [] as ArrayList<TokenSpan> CodeTokenizer.appendLiteralSpans(spans, "\"hi\\n\"", 0, 6, true, TokenKind.STRING) assert spans.size == 3