Class Parser<NumberT>

java.lang.Object
dk.jonaslindstrom.arithmeticparser.Parser<NumberT>
Type Parameters:
NumberT -

public class Parser<NumberT> extends Object
This class parses arithmetic expressions into reverse polish notation which makes them easy to evaluate. It supports basic arithmetic (+, -, *, /, ^) and parenthesis. It also supports user defined functions and variables to be assigned during evaluation.
  • Constructor Details

    • Parser

      public Parser(List<String> operators, NumberParser<NumberT> parser)
      Create a new operator recognizing the given operators and using the given parser to convert numbers into the desired type. Operators should be ordered with the least precedent first.
      Parameters:
      operators -
      parser -
  • Method Details

    • getDefault

      public static Parser<Double> getDefault()
      Return the default parser.
      Returns:
    • parse

      public List<Token> parse(String infix, List<String> variables, List<String> functions) throws ParseException
      Parse the given expression given lists of names of user defined variables and functions.
      Parameters:
      infix -
      variables -
      functions -
      Returns:
      Throws:
      ParseException