Class AST
-
-
Method Summary
Modifier and Type Method Description AST
assignVarValue(Map<HashString, ITreeNode<out Object>> matches)
This method substitutes variables present in matches map with their values. double
evaluation(Map<HashString, ITreeNode<out Object>> matches)
This evaluates the expression. ITreeNode<out Object>
getRoot()
Return the root Node of the tree. HashString
toHashString()
Similar to toString(), but returns a HashString. String
toString()
-
-
Method Detail
-
assignVarValue
AST assignVarValue(Map<HashString, ITreeNode<out Object>> matches)
This method substitutes variables present in matches map with their values. It must involve only node of Typ=Var. The method must also recognize the values type stored in the map (they can be Const or Num).
- Parameters:
matches
- the map with variable values already assigned.- Returns:
a new ITree containing the instantiated variable
-
evaluation
double evaluation(Map<HashString, ITreeNode<out Object>> matches)
This evaluates the expression. If the matches map contains values which are not instanced, and the expression value cannot consequently be computed, 0d is returned.
- Parameters:
matches
- the map that binds each variable with its own value- Returns:
A number representing the value for this expression. If the expression can't be computed, an exception is thrown.
-
getRoot
ITreeNode<out Object> getRoot()
Return the root Node of the tree.
- Returns:
the root element.
-
toHashString
HashString toHashString()
Similar to toString(), but returns a HashString.
- Returns:
a HashString representation of this Object
-
-
-
-