Parsing Mathematical Expressions in Java
Below applet shows example of the basic parsing and evaluating capabilities of JbcParser. You can set the built in X, Y variables, type a mathematical function and click the
evaluate button. The component that is used in the below applet is a time limited trial version of JbcParser.
You can also create custom variables by specifying it’s name and value and clicking the add button.
This applet demonstrates some of the parser’s features. To name a few, these features are:
Various default functions.
Functions can be declared to take any number of parameters.
Valid function and parameter names start with a letter and can contain letters, “_” and numbers.
Users can add functions/variables.
Function parameter values are not calculated until the moment they are used inside the function they are passed to. This allows the ability for example to have an IF(BOOL, A, B)
function where B is not calculated if BOOL is true and A is calculated and returned.
Logical Operators: <, >, =, &, |, !, %, <>, >=,<=
Ability to query if a variable is used in the current expression (below you can set X=”hello” and applet will not complain if X is not used in your expression).
Ability to query the current value of a variable.
Release version comes with full Java source code.
The example uses Sun’s Java Plugin which is an ActiveX control for IE and a plugin for Firefox If you do not have it, your browser should prompt you to download it. In case
things do not work, you can find information about the Java plugin at: http://java.sun.com/products/plugin/
If the Applet doesn’t start when you load this page, you may want to update your Java Plugin for your browser.