torero.model
Class Token

java.lang.Object
  |
  +--torero.model.Symbol
        |
        +--torero.model.Token
All Implemented Interfaces:
Comparable, Serializable

public class Token
extends Symbol
implements Serializable

Token Symbol Objects are used in Toreros Attribute Grammar Model to represent Tokens aka Terminal Symbols. As Terminal Symbols usually have a Regular Expression defined by the scanner it is possible to set this expression via setWord(). Some extensions were added to store Yacc specific features (association type and level).

See Also:
AttributeGrammar, SymbolMap, Serialized Form

Field Summary
static String LEFT
           
static String NONASSOC
           
static String RIGHT
           
 
Constructor Summary
protected Token(String name, String word, SymbolMap sm)
          This constuctor should not be called directly.
 
Method Summary
 void clearAssoc()
          Clear association type and level (yacc specific).
 String getAssocType()
          Return association type of this Token (yacc specific).
 int getPrecedence()
          Returns association level of this Token (yacc specific).
 String getWord()
          Return the expression described by this Token.
 boolean isLeaf()
          Returns true because Tokens are Leaf Symbols.
 boolean isLiteral()
          Returns it this Token is either a Literal or not (Literals are Tokens with equal Name and Expression).
 void setAssoc(String assocType, int precLevel)
          Sets the association type and level (yacc specific).
 void setTokenNumber(int toknum)
          Sets the token number this Token should have (yacc specific).
 void setWord(String word)
          Sets the word expression for this Token.
 StringBuffer toOxDecl(StringBuffer sb)
          Support for Ox File generation.
 String toString()
          Returns String representation for this Token.
 
Methods inherited from class torero.model.Symbol
addAttribute, changeName, compareTo, equals, getAttributePos, getAttributes, getAttributesSize, getName, getStringRep, hasAttribute, isEpsilon, removeAttribute, toDot, toOx
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

NONASSOC

public static final String NONASSOC

LEFT

public static final String LEFT

RIGHT

public static final String RIGHT
Constructor Detail

Token

protected Token(String name,
                String word,
                SymbolMap sm)
This constuctor should not be called directly. To get an instance of a Token use the SymbolMap class.
Method Detail

getWord

public String getWord()
Return the expression described by this Token.
Returns:
the expression described by this Token

setWord

public void setWord(String word)
Sets the word expression for this Token.
Parameters:
word - takes the (regular) expression for this Token

setAssoc

public void setAssoc(String assocType,
                     int precLevel)
Sets the association type and level (yacc specific).

clearAssoc

public void clearAssoc()
Clear association type and level (yacc specific).

getPrecedence

public int getPrecedence()
Returns association level of this Token (yacc specific).
Returns:
association level of this Token (yacc specific)

getAssocType

public String getAssocType()
Return association type of this Token (yacc specific).
Returns:
association type of this Token (yacc specific)

setTokenNumber

public void setTokenNumber(int toknum)
Sets the token number this Token should have (yacc specific).
Parameters:
takes - the number this token should have (yacc specific)

toString

public String toString()
Returns String representation for this Token.
Overrides:
toString in class Object
Returns:
String representation for this Token

isLeaf

public boolean isLeaf()
Returns true because Tokens are Leaf Symbols.
Overrides:
isLeaf in class Symbol
Returns:
true because Tokens are Leaf Symbols

isLiteral

public boolean isLiteral()
Returns it this Token is either a Literal or not (Literals are Tokens with equal Name and Expression).
Overrides:
isLiteral in class Symbol
Returns:
either this Token is a Literal or not (Literals are Tokens with equal Name and Expression

toOxDecl

public StringBuffer toOxDecl(StringBuffer sb)
Support for Ox File generation.
Overrides:
toOxDecl in class Symbol
Following copied from class: torero.model.Symbol
Parameters:
sb - the StringBuffer to write onto