Class MathResolver


  • public class MathResolver
    extends Object
    This is a helper class for resolving arithmetic operations over GroupingExpression objects. To resolve an operation simply push operator-expression pairs onto it, before calling resolve() to retrieve the single corresponding grouping expression object.
    Author:
    Simon Thoresen Hult
    • Constructor Detail

      • MathResolver

        public MathResolver()
    • Method Detail

      • push

        public void push​(MathResolver.Type type,
                         GroupingExpression exp)
        Pushes the given operator-expression pair onto this math resolver. Once all pairs have been pushed using this method, call resolve() to retrieve to combined grouping expression.
        Parameters:
        type - The operator that appears before the expression being pushed.
        exp - The expression to push.
      • resolve

        public GroupingExpression resolve()
        Converts the internal list of operator-expression pairs into a corresponding combined grouping expression. When this method returns there is no residue of the conversion, and this object can be reused.
        Returns:
        The grouping expression corresponding to the pushed arithmetic operations.