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 |
|---|---|
| public static class | STLexer.
We build |
| Modifier and Type | Field and Description |
|---|---|
| public static final int | |
| public static final int | |
| public static final int | |
| pack-priv char | c
current character |
| public static final int | |
| public static final int | |
| public static final int | |
| pack-priv char | delimiterStartChar
The char which delimits the start of an expression. |
| pack-priv char | delimiterStopChar
The char which delimits the end of an expression. |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final char | |
| public static final int | |
| public static final int | |
| pack-priv ErrorManager | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| pack-priv CharStream | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| public static final int | |
| pack-priv boolean | scanningInsideExpr
This keeps track of the current mode of the lexer. |
| public static final int | |
| public static final Token | |
| public static final int | |
| pack-priv int | startCharIndex
When we started token, track initial coordinates so we can properly build token objects. |
| pack-priv int | |
| pack-priv int | |
| public static final int | |
| public int | subtemplateDepth
To be able to properly track the inside/outside mode, we need to track how deeply nested we are in some templates. |
| public static final int | |
| pack-priv Token | templateToken
template embedded in a group file? |
| public static final int | |
| pack-priv List | tokens
Our lexer routines might have to emit more than a single token. |
| public static final int |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | STLexer(ErrorManager errMgr, CharStream input, Token templateToken, char delimiterStartChar, char delimiterStopChar)
|
| Modifier and Type | Method and Description |
|---|---|
| public Token | |
| pack-priv Token | |
| protected void | |
| public void | |
| pack-priv Token | |
| public String | getSourceName()
Implements org. |
| protected Token | |
| public static boolean | |
| public static boolean | |
| public static boolean | |
| public static boolean | |
| pack-priv void | |
| public void | |
| pack-priv Token | |
| pack-priv Token | |
| pack-priv Token | |
| public Token | |
| public Token | |
| public Token | |
| public Token | |
| public Token | nextToken()
Implements org. |
| protected Token | |
| public static String | |
| pack-priv Token | |
| pack-priv Token | |
| pack-priv void |
| AND | back to summary |
|---|---|
| public static final int AND | |
| AT | back to summary |
|---|---|
| public static final int AT | |
| BANG | back to summary |
|---|---|
| public static final int BANG | |
| c | back to summary |
|---|---|
| pack-priv char c current character | |
| COLON | back to summary |
|---|---|
| public static final int COLON | |
| COMMA | back to summary |
|---|---|
| public static final int COMMA | |
| COMMENT | back to summary |
|---|---|
| public static final int COMMENT | |
| delimiterStartChar | back to summary |
|---|---|
| pack-priv char delimiterStartChar The char which delimits the start of an expression. | |
| delimiterStopChar | back to summary |
|---|---|
| pack-priv char delimiterStopChar The char which delimits the end of an expression. | |
| DOT | back to summary |
|---|---|
| public static final int DOT | |
| ELLIPSIS | back to summary |
|---|---|
| public static final int ELLIPSIS | |
| ELSE | back to summary |
|---|---|
| public static final int ELSE | |
| ELSEIF | back to summary |
|---|---|
| public static final int ELSEIF | |
| ENDIF | back to summary |
|---|---|
| public static final int ENDIF | |
| EOF | back to summary |
|---|---|
| public static final char EOF | |
| EOF_TYPE | back to summary |
|---|---|
| public static final int EOF_TYPE | |
| EQUALS | back to summary |
|---|---|
| public static final int EQUALS | |
| errMgr | back to summary |
|---|---|
| pack-priv ErrorManager errMgr | |
| FALSE | back to summary |
|---|---|
| public static final int FALSE | |
| ID | back to summary |
|---|---|
| public static final int ID | |
| IF | back to summary |
|---|---|
| public static final int IF | |
| INDENT | back to summary |
|---|---|
| public static final int INDENT | |
| input | back to summary |
|---|---|
| pack-priv CharStream input | |
| LBRACK | back to summary |
|---|---|
| public static final int LBRACK | |
| LCURLY | back to summary |
|---|---|
| public static final int LCURLY | |
| LDELIM | back to summary |
|---|---|
| public static final int LDELIM | |
| LPAREN | back to summary |
|---|---|
| public static final int LPAREN | |
| NEWLINE | back to summary |
|---|---|
| public static final int NEWLINE | |
| OR | back to summary |
|---|---|
| public static final int OR | |
| PIPE | back to summary |
|---|---|
| public static final int PIPE | |
| RBRACK | back to summary |
|---|---|
| public static final int RBRACK | |
| RCURLY | back to summary |
|---|---|
| public static final int RCURLY | |
| RDELIM | back to summary |
|---|---|
| public static final int RDELIM | |
| REGION_END | back to summary |
|---|---|
| public static final int REGION_END | |
| RPAREN | back to summary |
|---|---|
| public static final int RPAREN | |
| scanningInsideExpr | back to summary |
|---|---|
| pack-priv boolean scanningInsideExpr This keeps track of the current mode of the lexer. Are we inside or outside an ST expression? | |
| SEMI | back to summary |
|---|---|
| public static final int SEMI | |
| SKIP | back to summary |
|---|---|
| public static final Token SKIP | |
| SLASH | back to summary |
|---|---|
| public static final int SLASH | |
| startCharIndex | back to summary |
|---|---|
| pack-priv int startCharIndex When we started token, track initial coordinates so we can properly build token objects. | |
| startCharPositionInLine | back to summary |
|---|---|
| pack-priv int startCharPositionInLine | |
| startLine | back to summary |
|---|---|
| pack-priv int startLine | |
| STRING | back to summary |
|---|---|
| public static final int STRING | |
| subtemplateDepth | back to summary |
|---|---|
| public int subtemplateDepth To be able to properly track the inside/outside mode, we need to
track how deeply nested we are in some templates. Otherwise, we
know whether a | |
| SUPER | back to summary |
|---|---|
| public static final int SUPER | |
| templateToken | back to summary |
|---|---|
| pack-priv Token templateToken template embedded in a group file? this is the template | |
| TEXT | back to summary |
|---|---|
| public static final int TEXT | |
| tokens | back to summary |
|---|---|
| pack-priv List<Token> tokens Our lexer routines might have to emit more than a single token. We buffer everything through this list. | |
| TRUE | back to summary |
|---|---|
| public static final int TRUE | |
| STLexer | back to summary |
|---|---|
| public STLexer(CharStream input) | |
| STLexer | back to summary |
|---|---|
| public STLexer(ErrorManager errMgr, CharStream input, Token templateToken) | |
| STLexer | back to summary |
|---|---|
| public STLexer(ErrorManager errMgr, CharStream input, Token templateToken, char delimiterStartChar, char delimiterStopChar) | |
| _nextToken | back to summary |
|---|---|
| public Token _nextToken() | |
| COMMENT | back to summary |
|---|---|
| pack-priv Token COMMENT() | |
| consume | back to summary |
|---|---|
| protected void consume() | |
| emit | back to summary |
|---|---|
| public void emit(Token token) | |
| ESCAPE | back to summary |
|---|---|
| pack-priv Token ESCAPE() | |
| getSourceName | back to summary |
|---|---|
| public String getSourceName() Implements org. Doc from org. Where are you getting tokens from? normally the implication will simply ask lexers input stream.
| |
| inside | back to summary |
|---|---|
| protected Token inside() | |
| isIDLetter | back to summary |
|---|---|
| public static boolean isIDLetter(char c) | |
| isIDStartLetter | back to summary |
|---|---|
| public static boolean isIDStartLetter(char c) | |
| isUnicodeLetter | back to summary |
|---|---|
| public static boolean isUnicodeLetter(char c) | |
| isWS | back to summary |
|---|---|
| public static boolean isWS(char c) | |
| LINEBREAK | back to summary |
|---|---|
| pack-priv void LINEBREAK() | |
| match | back to summary |
|---|---|
| public void match(char x) Consume if | |
| mID | back to summary |
|---|---|
pack-priv Token mID()
ID : ('a'..'z'|'A'..'Z'|'_'|'/')
('a'..'z'|'A'..'Z'|'0'..'9'|'_'|'/')*
;
| |
| mSTRING | back to summary |
|---|---|
pack-priv Token mSTRING()
STRING : '"'
( '\\' '"'
| '\\' ~'"'
| ~('\\'|'"')
)*
'"'
;
| |
| mTEXT | back to summary |
|---|---|
| pack-priv Token mTEXT() | |
| newToken | back to summary |
|---|---|
| public Token newToken(int ttype) | |
| newToken | back to summary |
|---|---|
| public Token newToken(int ttype, String text, int pos) | |
| newToken | back to summary |
|---|---|
| public Token newToken(int ttype, String text) | |
| newTokenFromPreviousChar | back to summary |
|---|---|
| public Token newTokenFromPreviousChar(int ttype) | |
| nextToken | back to summary |
|---|---|
| public Token nextToken() Implements org. Doc from org. Return a Token object from your input stream (usually a CharStream). Do not fail/return upon lexing error; keep chewing on the characters until you get a good one; errors are not passed through to the parser.
| |
| outside | back to summary |
|---|---|
| protected Token outside() | |
| str | back to summary |
|---|---|
| public static String str(int c) | |
| subTemplate | back to summary |
|---|---|
| pack-priv Token subTemplate() | |
| UNICODE | back to summary |
|---|---|
| pack-priv Token UNICODE() | |
| WS | back to summary |
|---|---|
| pack-priv void WS() | |
STToken tokens instead of relying on CommonToken
so we can override toString(). It just converts token types to
token names like 23 to "LDELIM".
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public String | toString()
Overrides org. |
| STToken | back to summary |
|---|---|
| public STToken(CharStream input, int type, int start, int stop) | |
| STToken | back to summary |
|---|---|
| public STToken(int type, String text) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides org. Doc from java. Returns a string representation of the object. | |