Class Description
Jep uses a set of components to parse and evaluate. They are:
  • INumberFactory
  • VariableFactory
  • NodeFactory
  • VariableTable
  • FunctionTable
  • OperatorTable
  • IParser
  • IEvaluator
  • PrintVisitor
Thrown when a exception is encountered during the evaluation process.
A table holding details of the functions known to Jep.
Base class for all exceptions thrown by Jep

The Jep class is the main interface with which the user should interact. It contains all necessary methods to parse and evaluate expressions.

To evaluate an expression, simply call the Parse(String) and Evaluate methods after each other. The following code snippet shows a parsing and evaluating a simple expression with a single variable:


JepInstance jep = new JepInstance();
jep.AddVariable("x", 10);
try {
    Object result = jep.Evaluate();
    System.Console.Out.WriteLine("x + 1 = " + result);
} catch (Exception e) {
    System.Console.Out.WriteLine("An error occured: " + e.getMessage());

The class is serializable. Please see the documentation section "Serialization" for more information on the various options for serializing.

This class is used to create nodes of specified types. It can be sub-classed to change the nature of how nodes are constructed. Generally there are two methods for creating nodes, methods which take an existing node and methods which take the components.
An Operator with additional information about its commutativity etc.

Operators have a number of properties:

  • A symbol or name of the operator "+".
  • The number of arguments NO_ARGS 0, UNARY 1 (e.g. UMINUS -x), BINARY 2 (e.g. x+y), and NARY either 3 ( a>b ? a : b) or unspecified like a list [x,y,z,w].
  • The binding of the operator, LEFT 1+2+3 -> (1+2)+3 or RIGHT 1=2=3 -> 1=(2=3).
  • Whether the operator is ASSOCIATIVE or COMMUTATIVE.
  • The precedence of the operators + has a higher precedence than *.
  • For unary operators they can either be PREFIX like -x or SUFFIX like x%.
  • Comparative operators can be REFLEXIVE, SYMMETRIC, TRANSITIVE or EQUIVALENCE which has all three properties.
  • A reference to a PostfixtMathCommandI object which is used to evaluate an equation containing the operator.
Various is... and get... methods are provided to query the properties of the operator.

Stores a list of operators.
Thrown when a exception is encountered during the parse process.
Prints an expression. Prints the expression with lots of brackets. ((-1.0)/sqrt((1.0-(x^2.0)))).


To use
JepInstance j = ...; INode in = ...;
j.Print(in, "x");
Information about a variable. Each variable has a name, and a value.

There is a flag to indicate whether it is a constant or not (constants cannot have their value changed). There is also a flag to indicate whether the value of the variable is valid. If the variable is initialized without a value then its value is said to be invalid.

This class extends java.util.Observable allowing observers to track if the variable value has been changed. Use addObserver(Observer o) to add an observer. When the variable value is changed the Observer's update(o, arg) method is called, the first argument is the Variable object and the second is the object representing the new value.

A factory class which is used to create variables.

By default this class creates variables of type Variable. This class should be sub-classed if the type of variable used needs to be changed.

This class is passed to the constructor of VariableTable which ensures that variables of the correct type are always created.

This class should only be called from the VariableTable class and not from application code.
A table of variables.

This class implements Observable and observers will be notified when new variables are added, or removed, but not when their values are changed. Use Variable.AddObserver() to monitor individual variables.


  Interface Description
Basic interface for evaluators
Base interface for all Jep components (parsers, evaluators etc).
This interface can be implemented to create numbers of any object type. By implementing this interface and calling the setNumberFactory() method of the JEP class, the constants in an expression will be created with that class.
Basic interface for a Jep parser
Basic interface that all ParserVisitors must implement.
Interface for a postfix math command.
This interface specifies the method needed to implement a special print rule. A special rule must implement the append method, which should call pv.append to add data to the output. For example


pv.AddSpecialRule(Operator.OP_LIST,new PrintVisitor.IPrintRules()
    public void Append(INode node, PrintVisitor pv) throws ParseException
        for(int i=0;i<node.JjtGetNumChildren();++i)
            if(i>0) pv.Append(",");
            node.JjtGetChild(i).JjtAccept(pv, null);