|
Venice 0.751beta | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectnz.org.venice.parser.expression.AbstractExpression
The abstract base class for all expressions in the Gondola language. This
class implements the Expression interface and provides functions for
managing an expression's child nodes. E.g. the expression 4+5 would
consist of three nodes. The plus being the root node, which would have two
child nodes of 4 and 5.
Expression| Field Summary |
| Fields inherited from interface nz.org.venice.parser.Expression |
BOOLEAN_TYPE, FALSE, FLOAT_QUOTE_TYPE, FLOAT_TYPE, INTEGER_QUOTE_TYPE, INTEGER_SHORT_TYPE, INTEGER_TYPE, NUMERIC_TYPE, STRING_TYPE, TRUE, TRUE_LEVEL, UNDEFINED_TYPE |
| Constructor Summary | |
AbstractExpression()
Create a new expression with no children. |
|
AbstractExpression(Expression[] children)
Create a new expression with the given number of children. |
|
AbstractExpression(java.util.List children)
Create a new expression with the given number of children. |
|
| Method Summary | |
abstract java.lang.Object |
clone()
|
boolean |
equals(java.lang.Object object)
Returns whether this expression tree and the given expression tree are equivalent. |
Expression |
getChild(int index)
Return the child of this node at the given index. |
java.lang.String |
getId()
|
int |
getIndex(Expression child)
Return the index of the given argument in the expression. |
static java.text.NumberFormat |
getNumberFormat()
|
Expression |
getParent()
Get the parent of this node. |
ParseMetadata |
getParseMetadata()
|
int |
hashCode()
If you override the equals(java.lang.Object) method then you should override
this method. |
boolean |
isRoot()
Return whether this node is the root node. |
java.util.Iterator |
iterator()
Return an iterator over the node's children. |
static double |
parseDouble(java.lang.String doubleText)
Parses doubleText from a string to produce a double. |
static int |
parseInt(java.lang.String intText)
Parses intText from a string to produce an integer. |
java.lang.String |
printParents()
|
Expression |
setChild(Expression child,
int index)
Set the argument. |
void |
setChildMutableVersion(Expression child,
int index)
Set this expression's child to the given child. |
void |
setParent(Expression parent)
Set the parent of this node. |
void |
setParseMetadata(java.util.HashMap parseTree,
java.util.HashMap tokenLineMap)
Store the metadata about how the expressing parsing. |
Expression |
simplify()
Perform simplifications and optimisations on the expression tree. |
Expression |
simplifyMutableVersion()
Perform simplifications and optimisations on the expression tree. |
int |
size()
Count the number of nodes in the tree. |
int |
size(int type)
Count the number of nodes in the tree with the given type. |
java.lang.String |
toString()
Convert the given expression to a string. |
boolean |
validTree()
Return true if none of the children of this expression are null. |
static java.lang.Double |
valueOfDouble(java.lang.String doubleText)
Parses doubleText from a string to produce a Double Object. |
static java.lang.Integer |
valueOfInt(java.lang.String intText)
Parses intText from a string to produce an Integer Object. |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface nz.org.venice.parser.Expression |
checkType, evaluate, getChildCount, getType |
| Constructor Detail |
public AbstractExpression()
public AbstractExpression(Expression[] children)
children - An array of the children of the expression.public AbstractExpression(java.util.List children)
children - A List of the children of the expression.| Method Detail |
public Expression getParent()
getParent in interface Expressionpublic void setParent(Expression parent)
setParent in interface Expressionparent - the new parent.public Expression getChild(int index)
getChild in interface Expressionindex - the argument index
public boolean isRoot()
isRoot in interface ExpressionTRUE iff this node is the root node.
public Expression setChild(Expression child,
int index)
Expression
setChild in interface Expressionchild - new argument expressionindex - index of the argument expression
public void setChildMutableVersion(Expression child,
int index)
child - the new child.index - the index of the new child.public boolean validTree()
validTree in interface Expressionpublic Expression simplify()
a and true then the
expression tree would be simplified to a.
simplify in interface Expressionpublic Expression simplifyMutableVersion()
a and true then the
expression tree would be simplified to a.
public int getIndex(Expression child)
getIndex in interface Expressionchild - the child expression to locate
-1 if it could
not be found
public static double parseDouble(java.lang.String doubleText)
throws java.lang.NumberFormatException
doubleText - the string to be parsed
java.lang.NumberFormatException
public static int parseInt(java.lang.String intText)
throws java.lang.NumberFormatException
intText - the string to be parsed
java.lang.NumberFormatException
public static java.lang.Double valueOfDouble(java.lang.String doubleText)
throws java.lang.NumberFormatException
doubleText - the string to be parsed
java.lang.NumberFormatException
public static java.lang.Integer valueOfInt(java.lang.String intText)
throws java.lang.NumberFormatException
intText - the string to be parsed
java.lang.NumberFormatExceptionpublic static java.text.NumberFormat getNumberFormat()
public boolean equals(java.lang.Object object)
equals in interface Expressionobject - the other expressionpublic int hashCode()
equals(java.lang.Object) method then you should override
this method. It provides a very basic hash code function.
hashCode in interface Expressionpublic int size()
size in interface Expressionpublic int size(int type)
size in interface Expressionpublic java.util.Iterator iterator()
iterator in interface Expressionpublic java.lang.String toString()
Expression
toString in interface Expressionpublic abstract java.lang.Object clone()
clone in interface Expressionpublic java.lang.String printParents()
public void setParseMetadata(java.util.HashMap parseTree,
java.util.HashMap tokenLineMap)
Expression
setParseMetadata in interface ExpressionparseTree - A map which relates a constructed expression with it's
associated token.tokenLineMap - A map which associates a token to which line number
of the rule text it appears.public ParseMetadata getParseMetadata()
getParseMetadata in interface Expressionpublic java.lang.String getId()
getId in interface Expression
|
Venice 0.751beta | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||