Interface TopLevelClass.Token

All Superinterfaces:
TopLevelClass.Node
All Known Implementing Classes:
TopLevelClass.Default.Token
Enclosing interface:
TopLevelClass

public static interface TopLevelClass.Token
extends TopLevelClass.Node

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.LexicalAnalyzers. 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., LexicalAnalyzers. Also, these methods may be unsuported and may throw UnsupportedOperationException.

Since:
notavaCC 1.0

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

getSymbolID

public int getSymbolID()
Returns the kind of this token.

The result value should be one of the followings:

valuedescribed token
TopLevelClass.EOF_TOKEN <EOF>
TopLevelClass.TOKEN_TERMINAL TERMINAL

Returns:
the kind of this token.
Since:
notavaCC 1.0

isWhite

public boolean isWhite()
Returnds true if this is a white token.

Returns:
true if this is a while token.
Since:
notavaCC 1.0

getImage

public String getImage()
Returns the string 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().

Returns:
the string this token corresponds to.
Since:
notavaCC 1.0
See Also:
getOriginalImage()

getOriginalImage

public String getOriginalImage()
Returns the string 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().

Returns:
the string this token corresponds to.
Since:
notavaCC 1.0
See Also:
getImage()

getSourceName

public String getSourceName()
                     throws UnsupportedOperationException
Returns the source name this token coressponds to.

Returns:
the source name this token coressponds to.
Throws:
UnsupportedOperationException - if the method is not suported.
Since:
notavaCC 1.0

getIndex

public int getIndex()
             throws UnsupportedOperationException
Returns the zero-based index number in the source where this token begins.

Returns:
the index number in the source where this token begins.
Throws:
UnsupportedOperationException - if the method is not suported.
Since:
notavaCC 1.0

getLine

public int getLine()
            throws UnsupportedOperationException
Returns the one-based line number in the source where this token begins.

Returns:
the line number in the source where this token begins.
Throws:
UnsupportedOperationException - if the method is not suported.
Since:
notavaCC 1.0

getColumn

public int getColumn()
              throws UnsupportedOperationException
Returns the one-based column number in the source where this token begins.

Returns:
the column number in the source where this token begins.
Throws:
UnsupportedOperationException - if the method is not suported.
Since:
notavaCC 1.0

toString

public String toString()
Returns the image and the position of this token if supported. For instance, `identifier' (line 2, column 3) or `identifier'. The format is not specified strictly.

Returns:
the image and the parenthesized position of this token.
Since:
notavaCC 1.0