Jasmine
1.1
Super fast expression and algorithm evaluator
|
Package Functions | |
Algorithm | getAlgorithm (String[] lines, boolean profileMe) throws JasmineException |
Static Package Functions | |
static CompileAlgorithm | getInstance () |
Private Member Functions | |
CompileAlgorithm () | |
List< Exp > | parse (int lineNo, String line, HashMap< String, Double > vars) throws JasmineException |
Exp | getExp (OperatorSet exprs, int type, String sequence, HashMap< String, Double > vars) |
Deque< Exp > | convertToAST (List< Exp > infix) throws JasmineException |
void | addNode (Deque< Exp > operandStack, Exp operator) throws JasmineException |
Private Attributes | |
OperatorSet | operatorSet = null |
Pattern[] | patterns |
Static Private Attributes | |
static CompileAlgorithm | instance = null |
Additional Inherited Members | |
Public Attributes inherited from org.quark.jasmine.CompileConstants | |
String | GENERATED_ALGORITHM_CLASS = "QuarkAlgorithm" |
String | GENERATED_EXPRESSION_CLASS = "QuarkExpression" |
String | EXPRESSION_CLASS = Type.getInternalName(Expression.class) |
String | EXPRESSION_CLASS_ID = Type.getDescriptor(Expression.class) |
String | ANSWER_CLASS = Type.getInternalName(Answer.class) |
String | ANSWER_CLASS_ID = Type.getDescriptor(Answer.class) |
Static Public Attributes inherited from org.quark.jasmine.CompileConstants | |
static String | ALGORITHM_CLASS = Type.getInternalName(Algorithm.class) |
static String | ALGORITHM_CLASS_ID = Type.getDescriptor(Algorithm.class) |
This is a singleton class used to compile Algorithms.
To evaluate an algorithm there are a number of steps
Initialising the compiler takes a long time compared to the other steps but fortunately it only done once on the first compilation. Alternatively you can force this step with
Compile.init();
when the application is starting up.
The compilation of the algorithm is faster but the use of variables means it can be done once and evaluated many times with different starting values.
The evaluation is blisteringly fast because it is executing Java byte code
|
private |
This private constructor gets the operator set to be used and creates the regular expressions used during parsing.
|
private |
Add a token to the AST
|
private |
Convert the infix list to AST (abstract syntax tree)
|
package |
Create and return the Algorithm.
lines | the Algorithm to compile |
profileMe | if true record the evaluation time |
JasmineException |
|
private |
Create a token from a matched sequence of characters. If the characters are 'spaces' then return null.
|
staticpackage |
Get the singleton instance.
|
private |
Parse an expression and return a list of tokens in infix order