| java.lang.Object com.go.tea.compiler.Token
All known Subclasses: com.go.tea.compiler.LongToken, com.go.tea.compiler.DoubleToken, com.go.tea.compiler.FloatToken, com.go.tea.compiler.IntToken, com.go.tea.compiler.StringToken,
Token | public class Token implements java.io.Serializable(Code) | | A Token represents the smallest whole element of a source file. Tokens are
produced by a
Scanner .
author: Brian S O'Neill version: 46 , 5/31/01 |
Field Summary | |
final public static int | AND | final public static int | ASSIGN | final public static int | BREAK | final public static int | CALL | final public static int | COMMA | final public static int | COMMENT Token ID for a single-line or multi-line comment. | final public static int | CONCAT | final public static int | DIV | final public static int | DOT | final public static int | DOTDOT | final public static int | DOUBLE_HASH | final public static int | ELLIPSIS | final public static int | ELSE | final public static int | ENTER_CODE Token ID for the start of a code region. | final public static int | ENTER_TEXT Token ID for the start of a text region. | final public static int | EOF Token ID for the end of file. | final public static int | EQ | final public static int | FALSE | final public static int | FOREACH | final public static int | GE | final public static int | GT | final public static int | HASH | final public static int | IDENT Token ID for an identifier. | final public static int | IF | final public static int | IN | final public static int | ISA | final public static int | LBRACE | final public static int | LBRACK | final public static int | LE | final public static int | LPAREN | final public static int | LT | final public static int | MINUS | final public static int | MOD | final public static int | MULT | final public static int | NE | final public static int | NOT | final public static int | NULL | final public static int | NUMBER Token ID for a number literal. | final public static int | OR | final public static int | PLUS | final public static int | RBRACE | final public static int | RBRACK | final public static int | REVERSE | final public static int | RPAREN | final public static int | SEMI | final public static int | SLASH | final public static int | STRING Token ID for a string literal. | final public static int | TEMPLATE | final public static int | TRUE | final public static int | UNKNOWN Token ID for an unknown token. |
Constructor Summary | |
| Token(int sourceLine, int sourceStartPos, int sourceEndPos, int tokenID) | | Token(int sourceLine, int sourceStartPos, int sourceEndPos, int sourceDetailPos, int tokenID) | public | Token(SourceInfo info, int tokenID) |
AND | final public static int AND(Code) | | Token ID for the and keyword: 'and'
|
ASSIGN | final public static int ASSIGN(Code) | | Token ID for the assignment operator: '='
|
BREAK | final public static int BREAK(Code) | | Token ID for the break keyword: 'break'
|
CALL | final public static int CALL(Code) | | Token ID for the call keyword: 'call'
|
COMMA | final public static int COMMA(Code) | | Token ID for the comma: ','
|
COMMENT | final public static int COMMENT(Code) | | Token ID for a single-line or multi-line comment.
|
CONCAT | final public static int CONCAT(Code) | | Token ID for the concatenation operator: '&'
|
DIV | final public static int DIV(Code) | | Token ID for the division operator: '/'
|
DOT | final public static int DOT(Code) | | Token ID for the dot: '.'
|
DOTDOT | final public static int DOTDOT(Code) | | Token ID for the double dot: '..'
|
DOUBLE_HASH | final public static int DOUBLE_HASH(Code) | | Token ID for the double hash: '##'
|
ELLIPSIS | final public static int ELLIPSIS(Code) | | Token ID for the ellipsis: '...'
|
ELSE | final public static int ELSE(Code) | | Token ID for the else keyword: 'else'
|
ENTER_CODE | final public static int ENTER_CODE(Code) | | Token ID for the start of a code region.
|
ENTER_TEXT | final public static int ENTER_TEXT(Code) | | Token ID for the start of a text region.
|
EOF | final public static int EOF(Code) | | Token ID for the end of file.
|
EQ | final public static int EQ(Code) | | Token ID for the equal operator: '=='
|
FALSE | final public static int FALSE(Code) | | Token ID for the false literal: 'false'
|
FOREACH | final public static int FOREACH(Code) | | Token ID for the for-each keyword: 'foreach'
|
GE | final public static int GE(Code) | | Token ID for the greater than or equal operator: '>='
|
GT | final public static int GT(Code) | | Token ID for the greater than operator: '>'
|
HASH | final public static int HASH(Code) | | Token ID for the hash: '#'
|
IDENT | final public static int IDENT(Code) | | Token ID for an identifier.
|
IF | final public static int IF(Code) | | Token ID for the if keyword: 'if'
|
IN | final public static int IN(Code) | | Token ID for the in keyword: 'in'
|
ISA | final public static int ISA(Code) | | Token ID for the is-a keyword: 'isa'
|
LBRACE | final public static int LBRACE(Code) | | Token ID for the left brace: '{'
|
LBRACK | final public static int LBRACK(Code) | | Token ID for the left bracket: '['
|
LE | final public static int LE(Code) | | Token ID for the less than or equal operator: '<='
|
LPAREN | final public static int LPAREN(Code) | | Token ID for the left parenthesis: '('
|
LT | final public static int LT(Code) | | Token ID for the less than operator: '<'
|
MINUS | final public static int MINUS(Code) | | Token ID for the minus operator: '-'
|
MOD | final public static int MOD(Code) | | Token ID for the modulus operator: '%'
|
MULT | final public static int MULT(Code) | | Token ID for the multiplication operator: '*'
|
NE | final public static int NE(Code) | | Token ID for the not equal operator: '!='
|
NOT | final public static int NOT(Code) | | Token ID for the not keyword: 'not'
|
NULL | final public static int NULL(Code) | | Token ID for the null literal: 'null'
|
NUMBER | final public static int NUMBER(Code) | | Token ID for a number literal.
|
OR | final public static int OR(Code) | | Token ID for the or keyword: 'or'
|
PLUS | final public static int PLUS(Code) | | Token ID for the plus operator: '+'
|
RBRACE | final public static int RBRACE(Code) | | Token ID for the right brace: '}'
|
RBRACK | final public static int RBRACK(Code) | | Token ID for the right bracket: ']'
|
REVERSE | final public static int REVERSE(Code) | | Token ID for the reverse keyword: 'reverse'
|
RPAREN | final public static int RPAREN(Code) | | Token ID for the right parenthesis: ')'
|
SEMI | final public static int SEMI(Code) | | Token ID for the semi-colon: ';'
|
SLASH | final public static int SLASH(Code) | | Token ID for the forward slash: '/'
|
STRING | final public static int STRING(Code) | | Token ID for a string literal.
|
TEMPLATE | final public static int TEMPLATE(Code) | | Token ID for the template keyword: 'template'
|
TRUE | final public static int TRUE(Code) | | Token ID for the true literal: 'true'
|
UNKNOWN | final public static int UNKNOWN(Code) | | Token ID for an unknown token.
|
Token | Token(int sourceLine, int sourceStartPos, int sourceEndPos, int tokenID)(Code) | | |
Token | Token(int sourceLine, int sourceStartPos, int sourceEndPos, int sourceDetailPos, int tokenID)(Code) | | |
dump | final public void dump()(Code) | | Dumps the contents of this Token to System.out.
|
dump | final public void dump(PrintStream out)(Code) | | Dumps the contents of this Token.
Parameters: out - The PrintStream to write to. |
findReservedWordID | public static int findReservedWordID(StringBuffer word)(Code) | | If the given StringBuffer starts with a valid token type, its ID is
returned. Otherwise, the token ID UNKNOWN is returned.
|
getCode | public String getCode()(Code) | | Token code is non-null, and is exactly the same as the name for its ID.
|
getDoubleValue | public double getDoubleValue()(Code) | | Only valid if token is a number.
|
getFloatValue | public float getFloatValue()(Code) | | Only valid if token is a number.
|
getID | final public int getID()(Code) | | Returns the ID of this Token, which identifies what type of token it is.
|
getImage | public String getImage()(Code) | | Token image represents what a static token looks like in a source file.
Token image is null if token is a string, number or identifier because
these tokens don't have static images.
|
getIntValue | public int getIntValue()(Code) | | Only valid if token is a number.
|
getLongValue | public long getLongValue()(Code) | | Only valid if token is a number.
|
getMatchingBracket | final public static int getMatchingBracket(int id)(Code) | | If the given id is a bracket: (,[,{,},],) then the matching bracket's
id is returned. If id is not a bracket, then -1 is returned.
|
getNumericType | public int getNumericType()(Code) | | Only valid if token is a number. Returns 0 if token is not a number
or is an invalid number. Returns 1 for int, 2 for long, 3 for
float and 4 for double. The token ID for all numbers (even invalid ones)
is NUMBER.
0, 1, 2, 3 or 4. |
getSourceInfo | final public SourceInfo getSourceInfo()(Code) | | Returns information regarding where in the source file this token
came from.
|
isBracket | final public static boolean isBracket(int id)(Code) | | Returns true if id is a bracket
Parameters: id - The Token id to test |
isBracket | final public boolean isBracket()(Code) | | Returns true if this Token is a bracket: (,[,{,},],)
|
isCloseBracket | final public static boolean isCloseBracket(int id)(Code) | | Returns true if id is a close bracket: ), ], }
Parameters: id - The Token id to test |
isCloseBracket | final public boolean isCloseBracket()(Code) | | Returns true if this Token is a close bracket: ),],}
|
isOpenBracket | final public static boolean isOpenBracket(int id)(Code) | | Returns true if id is an open bracket: (,[,{
Parameters: id - The Token id to test |
isOpenBracket | final public boolean isOpenBracket()(Code) | | Returns true if this Token is an open bracket: (,[,{
|
isOperator | final public static boolean isOperator(int id)(Code) | | Returns true if id is an operator
Parameters: id - The Token id to test |
isOperator | final public boolean isOperator()(Code) | | Returns true if this Token is an operator
|
isReservedWord | final public static boolean isReservedWord(int id)(Code) | | Returns true if id is a reserved word
Parameters: id - The Token id to test |
isReservedWord | final public boolean isReservedWord()(Code) | | Returns true if this Token is a reserved word.
|
|
|