tip.node
Class Token

java.lang.Object
  extended by tip.node.Node
      extended by tip.node.Token
All Implemented Interfaces:
Cloneable, NodeInterface
Direct Known Subclasses:
EOF, TAnd, TAssign, TComma, TCommentBlock, TCommentSingle, TDiv, TElse, TEq, TGt, TIdentifier, TIf, TInput, TIntegerConst, TLBrace, TLPar, TMalloc, TMinus, TNull, TOutput, TPlus, TRBrace, TReturn, TRPar, TSemicolon, TStar, TVar, TWhile, TWhiteSpace

public abstract class Token
extends Node

Token is the superclass of all tokens is the AST.


Method Summary
 void checkOptionalInvariant()
           
abstract  Token clone()
          Returns a deep clone of this Token node.
abstract  Token clone(Map<Node,Node> oldToNewMap)
          Creates a deep clone of this Token node while putting all old node-new node relations in the map oldToNewMap.
<T extends NodeInterface>
void
getChildren(Collection<T> collection, NodeFilter<T> filter)
          Adds all children of this Token node that are accepted by the NodeFilter filter to collection.
<T extends NodeInterface>
void
getDescendants(Collection<T> collection, NodeFilter<T> filter)
          Adds all descendants of this Token node (including the node itself) that are accepted by the NodeFilter filter to collection.
 int getLine()
          Returns the line number information of this token.
 int getPos()
          Returns the position information of this token.
 String getText()
          Returns the text from the input file from which this token was made.
 Token getToken()
          Returns the original token for this token.
 NodeEnum kindNode()
          Returns the NodeEnum corresponding to the type of this Node node.
abstract  TokenEnum kindToken()
          Returns the TokenEnum corresponding to the type of this Token node.
 void setLine(int line)
          Sets the line number information of this token.
 void setPos(int pos)
          Sets the position information of this token.
 void setText(String text)
          Sets the text of this token.
 String toString()
          Returns a textual representation of this Token node.
 
Methods inherited from class tip.node.Node
apply, apply, apply, apply, getAncestor, getAncestor, getAncestor, getChildren, getChildren, getDescendants, getDescendants, getDescendants, isOptionalInvariant, parent, replaceBy, setOptionalInvariant
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Method Detail

clone

public abstract Token clone()
Returns a deep clone of this Token node.

Specified by:
clone in interface NodeInterface
Specified by:
clone in class Node
Returns:
a deep clone of this Token node

clone

public abstract Token clone(Map<Node,Node> oldToNewMap)
Creates a deep clone of this Token node while putting all old node-new node relations in the map oldToNewMap.

Specified by:
clone in interface NodeInterface
Specified by:
clone in class Node
Parameters:
oldToNewMap - the map filled with the old node-new node relation
Returns:
a deep clone of this Token node

kindToken

public abstract TokenEnum kindToken()
Returns the TokenEnum corresponding to the type of this Token node.

Returns:
the TokenEnum for this node

kindNode

public NodeEnum kindNode()
Returns the NodeEnum corresponding to the type of this Node node.

Specified by:
kindNode in class Node
Returns:
the NodeEnum for this node

getToken

public Token getToken()
Returns the original token for this token.

Returns:
the original token for this token

getText

public String getText()
Returns the text from the input file from which this token was made.

Returns:
the text from the input file from which this token was made

setText

public void setText(String text)
Sets the text of this token.

Parameters:
text - the new text of this token

getLine

public int getLine()
Returns the line number information of this token.

Returns:
the line number information of this token

setLine

public void setLine(int line)
Sets the line number information of this token.

Parameters:
line - the new line number information of this token

getPos

public int getPos()
Returns the position information of this token.

Returns:
the position information of this token

setPos

public void setPos(int pos)
Sets the position information of this token.

Parameters:
pos - the new position information of this token

toString

public String toString()
Returns a textual representation of this Token node.

Overrides:
toString in class Object
Returns:
a textual representation of this Token node

getDescendants

public <T extends NodeInterface> void getDescendants(Collection<T> collection,
                                                     NodeFilter<T> filter)
Adds all descendants of this Token node (including the node itself) that are accepted by the NodeFilter filter to collection.

Specified by:
getDescendants in interface NodeInterface
Specified by:
getDescendants in class Node
Parameters:
collection - the collection to which the descendants are added
filter - the NodeFilter used

getChildren

public <T extends NodeInterface> void getChildren(Collection<T> collection,
                                                  NodeFilter<T> filter)
Adds all children of this Token node that are accepted by the NodeFilter filter to collection.

Specified by:
getChildren in interface NodeInterface
Specified by:
getChildren in class Node
Parameters:
collection - the collection to which the children are added
filter - the NodeFilter used

checkOptionalInvariant

public void checkOptionalInvariant()
Specified by:
checkOptionalInvariant in interface NodeInterface
Specified by:
checkOptionalInvariant in class Node