|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.teatrove.tea.compiler.Token
public class Token
A Token represents the smallest whole element of a source file. Tokens are
produced by a Scanner.
| Field Summary | |
|---|---|
static int |
AND
Token ID for the and keyword: 'and' |
static int |
AS
Token ID for the as keyword: 'as' |
static int |
ASSIGN
Token ID for the assignment operator: '=' |
static int |
BREAK
Token ID for the break keyword: 'break' |
static int |
CALL
Token ID for the call keyword: 'call' |
static int |
CLASS
Token ID for the class keyword: 'class' |
static int |
COLON
Token ID for colon: ':' |
static int |
COMMA
Token ID for the comma: ',' |
static int |
COMMENT
Token ID for a single-line or multi-line comment. |
static int |
CONCAT
Token ID for the concatenation operator: '&' |
static int |
CONTINUE
Token ID for the continue keyword: 'continue' |
static int |
DEFINE
Token ID for the define keyword: 'define' |
static int |
DIV
Token ID for the division operator: '/' |
static int |
DOT
Token ID for the dot: '.' |
static int |
DOTDOT
Token ID for the double dot: '..' |
static int |
DOUBLE_HASH
Token ID for the double hash: '##' |
static int |
ELLIPSIS
Token ID for the ellipsis: '...' |
static int |
ELSE
Token ID for the else keyword: 'else' |
static int |
ENTER_CODE
Token ID for the start of a code region. |
static int |
ENTER_TEXT
Token ID for the start of a text region. |
static int |
EOF
Token ID for the end of file. |
static int |
EQ
Token ID for the equal operator: '==' |
static int |
EQUAL_GREATER
Token ID for equal greater: '=>' |
static int |
FALSE
Token ID for the false literal: 'false' |
static int |
FOREACH
Token ID for the for-each keyword: 'foreach' |
static int |
GE
Token ID for the greater than or equal operator: '>=' |
static int |
GT
Token ID for the greater than operator: '>' |
static int |
HASH
Token ID for the hash: '#' |
static int |
IDENT
Token ID for an identifier. |
static int |
IF
Token ID for the if keyword: 'if' |
static int |
IMPORT
Token ID for the import keyword: 'import' |
static int |
IN
Token ID for the in keyword: 'in' |
static int |
ISA
Token ID for the is-a keyword: 'isa' |
static int |
LAMBDA
Token ID for lambda operator: '->' |
static int |
LBRACE
Token ID for the left brace: '{' |
static int |
LBRACK
Token ID for the left bracket: '[' |
static int |
LE
Token ID for the less than or equal operator: '<=' |
static int |
LPAREN
Token ID for the left parenthesis: '(' |
static int |
LT
Token ID for the less than operator: '<' |
static int |
MINUS
Token ID for the minus operator: '-' |
static int |
MOD
Token ID for the modulus operator: '%' |
static int |
MULT
Token ID for the multiplication operator: '*' |
static int |
NE
Token ID for the not equal operator: '!=' |
static int |
NOT
Token ID for the not keyword: 'not' |
static int |
NULL
Token ID for the null literal: 'null' |
static int |
NUMBER
Token ID for a number literal. |
static int |
OR
Token ID for the or keyword: 'or' |
static int |
PLUS
Token ID for the plus operator: '+' |
static int |
QUESTION
Token ID for question mark: '?' |
static int |
RBRACE
Token ID for the right brace: '}' |
static int |
RBRACK
Token ID for the right bracket: ']' |
static int |
REVERSE
Token ID for the reverse keyword: 'reverse' |
static int |
RPAREN
Token ID for the right parenthesis: ')' |
static int |
SEMI
Token ID for the semi-colon: ';' |
static int |
SLASH
Token ID for the forward slash: '/' |
static int |
SPACESHIP
Token ID for spaceship (comparator) operator: '<=>' |
static int |
SPREAD
Token ID for spread operator: *. |
static int |
STRING
Token ID for a string literal. |
static int |
TEMPLATE
Token ID for the template keyword: 'template' |
static int |
TRUE
Token ID for the true literal: 'true' |
static int |
UNKNOWN
Token ID for an unknown token. |
| Constructor Summary | |
|---|---|
Token(SourceInfo info,
int tokenID)
|
|
| Method Summary | |
|---|---|
void |
dump()
Dumps the contents of this Token to System.out. |
void |
dump(PrintStream out)
Dumps the contents of this Token. |
static int |
findReservedWordID(StringBuilder word)
If the given StringBuilder starts with a valid token type, its ID is returned. |
String |
getCode()
Token code is non-null, and is exactly the same as the name for its ID. |
double |
getDoubleValue()
Only valid if token is a number. |
float |
getFloatValue()
Only valid if token is a number. |
int |
getID()
Returns the ID of this Token, which identifies what type of token it is. |
String |
getImage()
Token image represents what a static token looks like in a source file. |
int |
getIntValue()
Only valid if token is a number. |
long |
getLongValue()
Only valid if token is a number. |
static int |
getMatchingBracket(int id)
If the given id is a bracket: (,[,{,},],) then the matching bracket's id is returned. |
int |
getNumericType()
Only valid if token is a number. |
SourceInfo |
getSourceInfo()
Returns information regarding where in the source file this token came from. |
String |
getStringValue()
|
boolean |
isBracket()
Returns true if this Token is a bracket: (,[,{,},],) |
static boolean |
isBracket(int id)
Returns true if id is a bracket |
boolean |
isCloseBracket()
Returns true if this Token is a close bracket: ),],} |
static boolean |
isCloseBracket(int id)
Returns true if id is a close bracket: ), ], } |
boolean |
isOpenBracket()
Returns true if this Token is an open bracket: (,[,{ |
static boolean |
isOpenBracket(int id)
Returns true if id is an open bracket: (,[,{ |
boolean |
isOperator()
Returns true if this Token is an operator |
static boolean |
isOperator(int id)
Returns true if id is an operator |
boolean |
isReservedWord()
Returns true if this Token is a reserved word. |
static boolean |
isReservedWord(int id)
Returns true if id is a reserved word |
String |
toString()
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
public static final int UNKNOWN
public static final int EOF
public static final int COMMENT
public static final int ENTER_CODE
public static final int ENTER_TEXT
public static final int STRING
public static final int NUMBER
public static final int IDENT
public static final int LPAREN
public static final int RPAREN
public static final int LBRACE
public static final int RBRACE
public static final int LBRACK
public static final int RBRACK
public static final int SEMI
public static final int COMMA
public static final int DOT
public static final int DOTDOT
public static final int ELLIPSIS
public static final int SLASH
public static final int HASH
public static final int DOUBLE_HASH
public static final int LT
public static final int LE
public static final int EQ
public static final int GE
public static final int GT
public static final int NE
public static final int CONCAT
public static final int PLUS
public static final int MINUS
public static final int MULT
public static final int DIV
public static final int MOD
public static final int ASSIGN
public static final int EQUAL_GREATER
public static final int COLON
public static final int QUESTION
public static final int LAMBDA
public static final int SPACESHIP
public static final int SPREAD
public static final int NULL
public static final int TRUE
public static final int FALSE
public static final int NOT
public static final int OR
public static final int AND
public static final int IF
public static final int ELSE
public static final int ISA
public static final int FOREACH
public static final int IN
public static final int REVERSE
public static final int TEMPLATE
public static final int CALL
public static final int BREAK
public static final int DEFINE
public static final int AS
public static final int IMPORT
public static final int CONTINUE
public static final int CLASS
| Constructor Detail |
|---|
public Token(SourceInfo info,
int tokenID)
| Method Detail |
|---|
public static final boolean isReservedWord(int id)
id - The Token id to testpublic static final boolean isOperator(int id)
id - The Token id to testpublic static final boolean isBracket(int id)
id - The Token id to testpublic static final boolean isOpenBracket(int id)
id - The Token id to testpublic static final boolean isCloseBracket(int id)
id - The Token id to testpublic static final int getMatchingBracket(int id)
public static int findReservedWordID(StringBuilder word)
public final void dump()
public final void dump(PrintStream out)
out - The PrintStream to write to.public final int getID()
public final boolean isReservedWord()
public final boolean isBracket()
public final boolean isOpenBracket()
public final boolean isCloseBracket()
public final boolean isOperator()
public String getImage()
public String getCode()
public final SourceInfo getSourceInfo()
public String getStringValue()
public int getNumericType()
public int getIntValue()
public long getLongValue()
public float getFloatValue()
public double getDoubleValue()
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||