public class STLexer extends Object implements org.antlr.runtime.TokenSource
TokenSource
interface so it can be used with ANTLR parsers. Outside of expressions, we
can return these token types: TEXT
, INDENT
, LDELIM
(start of expression), RCURLY
(end of subtemplate), and
NEWLINE
. Inside of an expression, this lexer returns all of the
tokens needed by STParser
. From the parser's point of view, it can
treat a template as a simple stream of elements.
This class defines the token types and communicates these values to
STParser.g
via STLexer.tokens
file (which must remain
consistent).
Modifier and Type | Class and Description |
---|---|
static class |
STLexer.STToken
We build
STToken tokens instead of relying on CommonToken
so we can override STLexer.STToken.toString() . |
Modifier and Type | Field and Description |
---|---|
static int |
AND |
static int |
AT |
static int |
BANG |
static int |
COLON |
static int |
COMMA |
static int |
COMMENT |
static int |
DOT |
static int |
ELLIPSIS |
static int |
ELSE |
static int |
ELSEIF |
static int |
ENDIF |
static char |
EOF |
static int |
EOF_TYPE |
static int |
EQUALS |
static int |
FALSE |
static int |
ID |
static int |
IF |
static int |
INDENT |
static int |
LBRACK |
static int |
LCURLY |
static int |
LDELIM |
static int |
LPAREN |
static int |
NEWLINE |
static int |
OR |
static int |
PIPE |
static int |
RBRACK |
static int |
RCURLY |
static int |
RDELIM |
static int |
REGION_END |
static int |
RPAREN |
static int |
SEMI |
static org.antlr.runtime.Token |
SKIP |
static int |
STRING |
int |
subtemplateDepth
To be able to properly track the inside/outside mode, we need to
track how deeply nested we are in some templates.
|
static int |
SUPER |
static int |
TEXT |
static int |
TRUE |
Constructor and Description |
---|
STLexer(org.antlr.runtime.CharStream input) |
STLexer(ErrorManager errMgr,
org.antlr.runtime.CharStream input,
org.antlr.runtime.Token templateToken) |
STLexer(ErrorManager errMgr,
org.antlr.runtime.CharStream input,
org.antlr.runtime.Token templateToken,
char delimiterStartChar,
char delimiterStopChar) |
Modifier and Type | Method and Description |
---|---|
org.antlr.runtime.Token |
_nextToken() |
protected void |
consume() |
void |
emit(org.antlr.runtime.Token token) |
String |
getSourceName() |
protected org.antlr.runtime.Token |
inside() |
static boolean |
isIDLetter(char c) |
static boolean |
isIDStartLetter(char c) |
static boolean |
isUnicodeLetter(char c) |
static boolean |
isWS(char c) |
void |
match(char x)
Consume if
x is next character on the input stream. |
org.antlr.runtime.Token |
newToken(int ttype) |
org.antlr.runtime.Token |
newToken(int ttype,
String text) |
org.antlr.runtime.Token |
newToken(int ttype,
String text,
int pos) |
org.antlr.runtime.Token |
newTokenFromPreviousChar(int ttype) |
org.antlr.runtime.Token |
nextToken() |
protected org.antlr.runtime.Token |
outside() |
static String |
str(int c) |
public static final char EOF
public static final int EOF_TYPE
public static final org.antlr.runtime.Token SKIP
public static final int RBRACK
public static final int LBRACK
public static final int ELSE
public static final int ELLIPSIS
public static final int LCURLY
public static final int BANG
public static final int EQUALS
public static final int TEXT
public static final int ID
public static final int SEMI
public static final int LPAREN
public static final int IF
public static final int ELSEIF
public static final int COLON
public static final int RPAREN
public static final int COMMA
public static final int RCURLY
public static final int ENDIF
public static final int RDELIM
public static final int SUPER
public static final int DOT
public static final int LDELIM
public static final int STRING
public static final int PIPE
public static final int OR
public static final int AND
public static final int INDENT
public static final int NEWLINE
public static final int AT
public static final int REGION_END
public static final int TRUE
public static final int FALSE
public static final int COMMENT
public int subtemplateDepth
'}'
and the outermost subtemplate to send this
back to outside mode.public STLexer(org.antlr.runtime.CharStream input)
public STLexer(ErrorManager errMgr, org.antlr.runtime.CharStream input, org.antlr.runtime.Token templateToken)
public STLexer(ErrorManager errMgr, org.antlr.runtime.CharStream input, org.antlr.runtime.Token templateToken, char delimiterStartChar, char delimiterStopChar)
public org.antlr.runtime.Token nextToken()
nextToken
in interface org.antlr.runtime.TokenSource
public void match(char x)
x
is next character on the input stream.protected void consume()
public void emit(org.antlr.runtime.Token token)
public org.antlr.runtime.Token _nextToken()
protected org.antlr.runtime.Token outside()
protected org.antlr.runtime.Token inside()
public static boolean isIDStartLetter(char c)
public static boolean isIDLetter(char c)
public static boolean isWS(char c)
public static boolean isUnicodeLetter(char c)
public org.antlr.runtime.Token newToken(int ttype)
public org.antlr.runtime.Token newTokenFromPreviousChar(int ttype)
public org.antlr.runtime.Token newToken(int ttype, String text, int pos)
public org.antlr.runtime.Token newToken(int ttype, String text)
public String getSourceName()
getSourceName
in interface org.antlr.runtime.TokenSource
public static String str(int c)
Copyright © 2024. All rights reserved.