parser
Class ExpressionParser.Default.Token

java.lang.Object
  |
  +--parser.ExpressionParser.Default.Node
        |
        +--parser.ExpressionParser.Default.Token
All Implemented Interfaces:
ExpressionParser.Node, ExpressionParser.Token
Enclosing class:
ExpressionParser.Default

public static class ExpressionParser.Default.Token
extends ExpressionParser.Default.Node
implements ExpressionParser.Token

Provides a simple implementation of ExpressionParser.Token.

Since:
notavaCC 1.0

Constructor Summary
ExpressionParser.Default.Token(int symbolID, String image)
           
ExpressionParser.Default.Token(int symbolID, String image, String sourceName, int index, int line, int column)
          Constructs a token.
 
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 getSourceName()
          Returns the source name this token coressponds to.
 int getSymbolID()
          Returns the kind of this token.
 String toString()
          Returns the image and the parenthesized position of this token if supported.
 
Methods inherited from class parser.ExpressionParser.Default.Node
accept, getChildNodes, getParentNode, replace, replaceChild, setParentNode
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface parser.ExpressionParser.Node
accept, getChildNodes, getParentNode, setParentNode
 

Constructor Detail

ExpressionParser.Default.Token

public ExpressionParser.Default.Token(int symbolID,
                                      String image)

ExpressionParser.Default.Token

public ExpressionParser.Default.Token(int symbolID,
                                      String image,
                                      String sourceName,
                                      int index,
                                      int line,
                                      int column)
Constructs a token.

Parameters:
symbolID - the symbol ID of the token, returned by getSymbolID.
image - the image string, returned by getImage.
sourceName - the source name returned by getSourceName, or null if not supported.
index - the index returned by getIndex, or -1 if not supported.
line - the line number returned by getLine, or -1 if not supported.
column - the column number returned by getColumn, or -1 if not supported.
Since:
notavaCC 1.0
Method Detail

getSymbolID

public int getSymbolID()
Description copied from interface: ExpressionParser.Token
Returns the kind of this token.

The result value should be one of the followings:

valuedescribed token
EOF_TOKEN <EOF>
TOKEN_WHITE_SPACES WHITE_SPACES
TOKEN_TRADITIONAL_COMMENT TRADITIONAL_COMMENT
TOKEN_END_OF_LINE_COMMENT END_OF_LINE_COMMENT
TOKEN_INTEGER INTEGER
5 "("
6 ")"
7 "*"
8 "+"
9 "-"
10 "/"

Specified by:
getSymbolID in interface ExpressionParser.Token
Returns:
the kind of this token.

getImage

public String getImage()
Description copied from interface: ExpressionParser.Token
Returns the string this token corresponds to.

Specified by:
getImage in interface ExpressionParser.Token
Returns:
the string this token corresponds to.

getSourceName

public String getSourceName()
                     throws UnsupportedOperationException
Description copied from interface: ExpressionParser.Token
Returns the source name this token coressponds to.

Specified by:
getSourceName in interface ExpressionParser.Token
Returns:
the source name this token coressponds to. E.g. the canonical name of the file.
Throws:
UnsupportedOperationException - if the method is not suported.

getIndex

public int getIndex()
             throws UnsupportedOperationException
Description copied from interface: ExpressionParser.Token
Returns the zero-based index number in the source where this token begins.

Specified by:
getIndex in interface ExpressionParser.Token
Returns:
the index number in the source where this token begins.
Throws:
UnsupportedOperationException - if the method is not suported.

getLine

public int getLine()
            throws UnsupportedOperationException
Description copied from interface: ExpressionParser.Token
Returns the one-based line number in the source where this token begins.

Specified by:
getLine in interface ExpressionParser.Token
Returns:
the line number in the source where this token begins.
Throws:
UnsupportedOperationException - if the method is not suported.

getColumn

public int getColumn()
              throws UnsupportedOperationException
Description copied from interface: ExpressionParser.Token
Returns the one-based column number in the source where this token begins.

Specified by:
getColumn in interface ExpressionParser.Token
Returns:
the column number in the source where this token begins.
Throws:
UnsupportedOperationException - if the method is not suported.

toString

public String toString()
Description copied from interface: ExpressionParser.Token
Returns the image and the parenthesized position of this token if supported. E.g. "'identifier' (line 2, column 3)" or "'identifier'".

Specified by:
toString in interface ExpressionParser.Token
Overrides:
toString in class ExpressionParser.Default.Node
Returns:
the image and the parenthesized position of this token.