|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A token, which is a fragment of a parsed text.
A token is a fragment of a parsed text (a source). Tokens are usually constructed by TopLevelClass.LexicalAnalyzer
s. This class introduces the methods that represent what is the source of the token and where the token is placed in the source (getSourceName()
, getIndex()
, getLine()
, getColumn()
), however, the strict specification of the returned value is defined by the generator of the token, e.g., LexicalAnalyzer
s. Also, these methods may be unsuported and may throw UnsupportedOperationException
.
Method Summary | |
int |
getColumn()
Returns the one-based column number in the source where this token begins. |
String |
getImage()
Returns the string this token corresponds to.
|
int |
getIndex()
Returns the zero-based index number in the source where this token begins. |
int |
getLine()
Returns the one-based line number in the source where this token begins. |
String |
getOriginalImage()
Returns the string this token corresponds to.
|
String |
getSourceName()
Returns the source name this token coressponds to. |
int |
getSymbolID()
Returns the kind of this token.
|
boolean |
isWhite()
Returnds true if this is a white token.
|
String |
toString()
Returns the image and the position of this token if supported.
|
Methods inherited from interface TopLevelClass.Node |
accept, getChildNodes |
Method Detail |
public int getSymbolID()
this
token.
The result value should be one of the followings:
value | described token |
---|---|
TopLevelClass.EOF_TOKEN |
<EOF> |
TopLevelClass.TOKEN_TERMINAL |
TERMINAL |
this
token.public boolean isWhite()
true
if this
is a white token.
true
if this
is a while token.public String getImage()
this
token corresponds to.
If the string contains some meta notation like Unicode escapes, the returned value is the represented string (e.g., A) rather than the representation (e.g., A). If not, the returned value is the same as getOriginalImage()
.
this
token corresponds to.getOriginalImage()
public String getOriginalImage()
this
token corresponds to.
If the string contains some meta notation like Unicode escapes, the returned value is the representation (e.g., A) rather than the represented string (e.g., A). If not, the returned value is the same as getImage()
.
this
token corresponds to.getImage()
public String getSourceName() throws UnsupportedOperationException
this
token coressponds to.
this
token coressponds to.
UnsupportedOperationException
- if the method is not suported.public int getIndex() throws UnsupportedOperationException
this
token begins.
this
token begins.
UnsupportedOperationException
- if the method is not suported.public int getLine() throws UnsupportedOperationException
this
token begins.
this
token begins.
UnsupportedOperationException
- if the method is not suported.public int getColumn() throws UnsupportedOperationException
this
token begins.
this
token begins.
UnsupportedOperationException
- if the method is not suported.public String toString()
this
token if supported.
For instance, `identifier' (line 2, column 3)
or `identifier'
.
The format is not specified strictly.
this
token.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |