Version History
Jep 3 Releases | Jep 2 Releases | Jep 1 Releases
Version 3.4 (released 2010/11/01)
Core Jep changes
- Allow strings to be used together with BigDecimals so that strings can be concatenated with + and compared in relations.
- Added an EmptyOperatorTable which has zero operators as a default. A consequence of this is moving of the OperatorKey interface to EmptyOperatorTable.
- The Jep class now has a constructor taking a list of components; some methods made protected to allow sub-classes; has a
getAdditionComponent(Class<?>)
method to find components which instance a particular class.
- PrintVisitor adds an
append(String)
method allowing classes which implement PrintRulesI to append text to the output.
- The
VariableTable
has a new method clearValues()
which clears the valid-value flag of
all non constant values. Constants are always valid.
- The standard parser is now generated with JavaCC 5.0 (previously JavaCC 4.0)
Functions
- All function classes are no longer final to allow for sub-classing by users. Visibility of some methods increased to allow sub classing.
- The
round
function now uses Math.round and a new rint
function is added which calls Math.rint. These differ in how 1.5 is rounded (rint rounds up to nearest even value, round always rounds down).
- The Average function can be configured to change behaviour for zero length arrays, either NaN is returned or an Exception is thrown (the default). A
calc(List)
method makes it easier to create sub-classes which act on lists of objects.
- The MinMax function now flattens its arguments so
min([1,[2,3]])
can be computed. The Comparative parameter can be set by sub classes.
- The new VSum function sums the elements in a vector or matrix.
Configurable Parser
- New interfaces
TokenizerFactory
, GrammarParserFactory
which
allow different objects to be used for the tokenizing and parsing steps.
ShuntingYard
some methods made protected.
Tokenizer
constructor changed, line and column numbering starts from 1.
OperatorTokenMatcher
improved handling of operators with word characters.
GrammarParser
has an additional method public void setIterator(Lookahead2Iterator<Token>)
setting the iterator used by parseSubExpression()
.
Misc classes
MacroFunction
has an additional constructor for use with non recursive functions.
- A new package
com.singularsys.jep.misc.lineNumbering
to allow line number information to be stored in nodes in the parse tree. With classes LineNumberingNodeFactory
,
LineNumberingShuntingYard
.
- A new package
com.singularsys.jep.misc.nullwrapper
which provides functions and operators which propagate null values through results. These classes can be wrapped
around other classes to add this functionality to existing classes.
- Additional constructions provided for visitors in
com.singularsys.jep.walkers
so they can be used as JepComponents.
Tests and Examples
- JUnit Tests split into
system
and unit
packages.
Bug fixes
- Fixed bug with FastEvaluator when calling the same function twice.
- Fixed potential null reference exception in SimpleNode.hasNext()
- Fixed issue where PrintVisitor.getMode(int testmode) did not return the correct value.
Version 3.3 (released 2008/11/30)
Core Jep changes
- New default evaluator
FastEvaluator
which achieves a 2x-3x speed improvement using the new interfaces. StandardEvaluator is still available for compatibility purposes.
- New constructor
Jep(JepComponent... comp)
which makes it easier
to construct Jep with a specific set of components.
For example new Jep(new StandardConfigurableParser())
.
- New version of the operator table
OperatorTable2
which uses enums to specify keys. Methods that are common to all operator tables are
declared in a new interface
OperatorTableI.
Note that
Jep.getOperatorTable()
now returns OperatorTableI
which may break some code.
-
Node now defines default implementations
for
getName()
, getValue()
making it easier to extract values without a cast.
-
Node now defines methods
setHook()
, getHook()
allowing annotation of nodes with key-value pairs.
- Unit tests converted to use JUnit 4.
Functions
-
New functions
Switch,
Case, Left, Right, Mid, Substring, LowerCase, UpperCase, Length, Trim.
- New base classes
UnaryFunction,
BinaryFunction,
NaryFunction, and
NaryBinaryFunction
simplifying interface for defining user functions. For example, a
BinaryFunction
just needs to define an Object eval(Object l, Object r)
method.
-
New exception class
IllegalParameterException
sub-classing
EvaluationException
provides standardised error
messages, for the common case of wrong arguments being passed to user functions.
-
PostfixMathCommand
defines convenience methods such as
int asInt()
to convert arguments to a specified type.
-
New optional functions
IsNull,
IsNaN,
IsInfinite,
IsType
for testing the value and type of arguments. These are not included by default.
Examples
Version 3.2 (released 2008/02/12)
General Changes:
- Added support for expression tree analysis using TreeAnalyser
- Fixed errors in the documentation of the default configuration
- Improved the operator table
Changes to the configurable parser:
- New StandardConfigurableParser class
- Parse error reporting with line and column numbers
- Added support for hexadecimal numbers (e.g.
0x1F
)
- Added support for bitwise operators (bitwise or:
a | b
, bit shifting a << 2
) in BitwiseOperatorTable
- Added support for
a?b:c
, x+=1
, ++x
syntax
- Added support for case-insensitive operators
- Added support for multiple expressions separated by semicolons
- Added support for multiple dimensional array access (
a[1][1]
accesses the first element of a two-dimensional array)
- Fixed issues with escape characters
- Fixed power and unary minus precedence to be consistent with the standard parser ("-3^2" should equal -9)
Known issues:
Jep.addVariable
does not notify the user when the specified value can not be set. This happens when a constant is already defined with the same name.
Version 3.1 (released 2007/09/22)
- Added serialization support
- Fixes bug prohibiting adding alphabetic operators to the configurable parser (such as AND)
- Added short circuit logical operator evaluation for && and || to speed up evaluation
- Added
avg
, min
, and max
functions
- Makes use of new Java 1.5 Math functions
log10
, sinh
, cosh
, tanh
, and hypot
- Added StrictNaturalLogarithm which returns
NaN
for negative reals rather than complex.
- Fixed mistake in the Basic Usage section of the documentation
Known issues:
- The default settings for allowUndeclared, implicitMultiplication, and allowAssignment are true. The documentation falsely claims that the defaults are false.
Version 3.0 (released 2007/07/01)
- Added RealEvaluator for fast evaluation
of expressions not containing strings, arrays or complex numbers
- Added BigDecComponents for high
precision calculations using BigDecimal numbers
- New component architecture (pluggable
parser, evaluator, and more)
- Added new configurable parser (allows
alternate syntax)
- Added expression printing capabilities to the Jep class
- Added new functions: round, floor,
ceil, lg (log base 2)
- Major package restructuring
- No longer available under the GPL license
- Changed error handling from hasError()
function to exception throwing
- Switched from JavaCC 3.2 to JavaCC 4.0
- Switched compatibility from Java 1.2 to Java 1.5
- Switched from JUnit 3 to JUnit 4.1
- See Migration on how to smoothly upgrade from
a previous version
Known issues:
- The default settings for allowUndeclared, implicitMultiplication, and allowAssignment are true. The documentation falsely claims that the defaults are false.