klyn.code.CodeTokenizer.appendLiteralSpans
method
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
Description

Emits string content and escape spans (TokenKind.STRING and TokenKind.STRING_ESCAPE) for the literal segment line[start:end].

Parameters
ParameterDescription
spansDestination list of TokenSpans.
lineSource line text.
startInclusive start index of the literal segment.
endExclusive end index of the literal segment.
highlightEscapestrue to split valid backslash escape sequences into STRING_ESCAPE spans.
tokenKindBase token kind (TokenKind.STRING or TokenKind.CHARACTER).
Example
import klyn.code

spans = [] as ArrayList<TokenSpan>
CodeTokenizer.appendLiteralSpans(spans, "\"hi\\n\"", 0, 6, true, TokenKind.STRING)
assert spans.size == 3