com.agentfactory.common.parser
Class Token

java.lang.Object
  extended by com.agentfactory.common.parser.Token

public class Token
extends java.lang.Object

Tokens are the basic units of the scanning and parsing process. Tokens are created by the syntax scanner implementations in compliance with a given syntax for the source language. lists of tokens representing statements that are written in the source language are passed to the handlers, which attempt to construct a parse-tree for the statement. If successful, the parser takes the generated parse-tree and adds it to the program model.


Constructor Summary
Token(java.lang.String content, int row, java.lang.String source)
          Creates a new instance of Token
 
Method Summary
 boolean contentEquals(java.lang.String text)
          Comparator that compares some text with the content stored in the token.
 java.lang.String getContent()
          Accessor that returns the content associated with the token
 int getRow()
          Accessor that returns the row that the token was found on
 java.lang.String getSource()
          Accessor that returns the name of the source from which the token was retrieved.
 java.lang.String toString()
          String representation fo a token
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Token

public Token(java.lang.String content,
             int row,
             java.lang.String source)
Creates a new instance of Token

Parameters:
content - the content associated with the token.
row - the row (line) on which the token occurred.
source - the name of the source from which the token was taken.
Method Detail

getRow

public int getRow()
Accessor that returns the row that the token was found on

Returns:
a row number

getContent

public java.lang.String getContent()
Accessor that returns the content associated with the token

Returns:
a string representation of the token.

toString

public java.lang.String toString()
String representation fo a token

Overrides:
toString in class java.lang.Object
Returns:
a string

contentEquals

public boolean contentEquals(java.lang.String text)
Comparator that compares some text with the content stored in the token.

Parameters:
text - some text that is to be used for a comparison with the token.
Returns:
true is the text is the same as the token, false otherwise

getSource

public java.lang.String getSource()
Accessor that returns the name of the source from which the token was retrieved.

Returns:
a string containing the source name