public final class SourceText extends Object
TCustomLexer.readln). Re-parsed text (routine bodies, dynamic SQL) has its token lines and
columns shifted into the parent text while TSourceToken.offset stays relative to the inner text, so
only the (line, column) pair is trusted: lexerOffset(long, long) turns it into a UTF-16 offset of this text.Position) count lines from 1 with LF as the line end, columns in code
points from 1, and offsets in UTF-8 bytes from 0, as the reference validator checks them
(conformance/run.py, M1 SemanticStage.SourceText). position(int) gives that triple for a
UTF-16 offset.Immutable.
| Modifier and Type | Class and Description |
|---|---|
static class |
SourceText.Position
A SQL-LR position.
|
| Constructor and Description |
|---|
SourceText(String text) |
| Modifier and Type | Method and Description |
|---|---|
String |
getText() |
int |
lexerOffset(long line1,
long column1)
The UTF-16 offset of a lexer (line, column), or -1 when the pair lies outside the text.
|
boolean |
matches(int utf16Offset,
String fragment)
Whether
fragment occurs in the text at utf16Offset. |
SourceText.Position |
position(int utf16Offset)
The SQL-LR position of a UTF-16 offset, or
null when the offset is outside the text or inside a
surrogate pair. |
int |
utf8Length()
The UTF-8 length of the text.
|
public SourceText(String text)
public int utf8Length()
public int lexerOffset(long line1, long column1)
c
of a line is the offset lineStart + c - 1; a column past the end of its line is outside.public SourceText.Position position(int utf16Offset)
null when the offset is outside the text or inside a
surrogate pair.