Package codeanalysis
Class Evaluator
java.lang.Object
codeanalysis.Evaluator
The
Evaluator class is responsible for evaluating an expression syntax tree and computing the result.
It provides a method to evaluate the root expression syntax and return the computed result.
The evaluator supports evaluating different types of expressions, including numbers, binary expressions
(addition, subtraction, multiplication, and division), and parenthesized expressions.
Note: The evaluator throws an exception if it encounters an unexpected node or operator during evaluation.- Version:
- 1.0
- Author:
- Siyabend Urun
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionEvaluator(BoundExpression root, Map<VariableSymbol, Object> variables) Initializes a new instance of theEvaluatorclass with the specified root expression syntax. -
Method Summary
-
Constructor Details
-
Evaluator
Initializes a new instance of theEvaluatorclass with the specified root expression syntax.- Parameters:
root- The root expression syntax to evaluate.variables- The variables of the evaluator.
-
-
Method Details
-
evaluate
Evaluates the expression syntax tree and computes the result.- Returns:
- The computed result of the expression.
- Throws:
Exception- if an error occurs during evaluation.
-