Package codeanalysis

Class Evaluator

java.lang.Object
codeanalysis.Evaluator

public class Evaluator extends Object
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 Details

    • Evaluator

      public Evaluator(BoundExpression root, Map<VariableSymbol,Object> variables)
      Initializes a new instance of the Evaluator class with the specified root expression syntax.
      Parameters:
      root - The root expression syntax to evaluate.
      variables - The variables of the evaluator.
  • Method Details

    • evaluate

      public Object evaluate() throws Exception
      Evaluates the expression syntax tree and computes the result.
      Returns:
      The computed result of the expression.
      Throws:
      Exception - if an error occurs during evaluation.