- JavaDoc

# JEP

- Introduction
- Basic Usage
- Variables
- Data types
- Operators
- Functions
- Custom Functions
- BigDecimal
- FAQ
- Migration
- Version History

# Advanced Features

- Manipulating Expressions
- Components
- Configurable Parser
- Serialization
- Grammar

# Component Architecture

With Jep 3.0, a new component architecture was introduced. It allows pluggable components, giving tremendous flexibility for customizing Jep. A total of 9 components are employed, as shown below.

- Parser
- Evaluator
- VariableTable
- FunctionTable
- OperatorTable
- VariableFactory
- NumberFactory
- NodeFactory
- PrintVisitor

For each of the components you can either use a built-in implementation, or you can create your own implementation.

The roles of these components are:

- Parser - parses expressions.
- Evaluator - evaluates expressions.
- VariableTable - stores the set of variables.
- FunctionTable - stores the sets of known functions.
- OperatorTable - stores the set of operators.
- VariableFactory - creates new variables.
- NumberFactory - creates objects representing numbers (typically Double) from string representations.
- NodeFactory - creates nodes in the parse tree.
- PrintVisitor - prints equations.

A set of components can be bundled together in a ComponentSet and the Jep(ComponentSet cs) constructor used to create a jep instance with a given set. Individual components can be set using jep.setComponent(JepComponent comp).

## Built-in components

Jep comes with many components built-in. When creating a `Jep` instance using the default constructor, the `StandardComponents` set is loaded. The standard components include the standard parser and the fast evaluator. In addition to those the ConfigurableParser and the RealEvaluator are also available. The following listing gives an overview of the components available in Jep 3.

StandardComponents (the default component set)
com.singularsys.jep.standard.StandardComponents

- StandardParser (JavaCC generated parser)
- FastEvaluator
- VariableFactory
- DoubleNumberFactory
- NodeFactory
- StandardVariableTable
- StandardFunctionTable
- StandardOperatorTable

BigDecimalComponents (see Big Decimals)

- BigDecFunctionTable (initializes a set a functions that can handle BigDecimals)
- BigDecNumberFactory (creates BigDecimal numbers)
- BigDecOperatorTable (initializes BigDecimal operators)

Other components

- RealEvaluator (allows fast evaluation of `double` arithmetic and functions)
- StandardEvaluator (the pre-v3.3 evaluator, kept for compatibility)
- PostfixEvaluator (traverses trees without using recursion, for very lage expressions)
- CaseInsensitiveFunctionTable (a function table which is case-insensitive)
- CaseInsensitiveVariableTable (a variable table which is case-insensitive)
- Configurable Parser (for customizable syntax)
- NullParser (a do-nothing parser)

## Custom components

The architecture also allows for new custom components can be loaded. These should implement the appropriate interface or extend the appropriate class. Two methods are common to all components (see JepComponent):

- `void init(Jep jep)` this is called after the Jep instance is constructed or when a component is changed and is used to inform all active components about the configuration. A do nothing method is typical.
- `public JepComponent getLightWeightInstance()` in multi-threaded environments with multiple Jep instances some components can be shared, but other need a separate instance per thread. This method returns an appropriate instance, which can be `this`, `null` or a new instance. See Serialization for details.