Jasmine
1.1
Super fast expression and algorithm evaluator
|
Package Functions | |
Expression | getExpression (String line, boolean profileMe) throws JasmineException |
Static Package Functions | |
static CompileExpression | getInstance () |
Static Package Attributes | |
static final int | WHITESPACE = 0 |
static final int | FLOAT1 = 1 |
static final int | FLOAT2 = 2 |
static final int | INT = 3 |
static final int | VARIABLE = 4 |
static final int | OPERATOR = 5 |
Private Member Functions | |
CompileExpression () | |
List< Exp > | parse (String line) throws JasmineException |
Exp | getExp (OperatorSet exprs, int type, String sequence, HashMap< String, Integer > indices) |
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 CompileExpression | 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 Expressions.
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 expression 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)
|
private |
Create a token from a matched sequence of characters. If the characters are 'spaces' then return null.
|
package |
Create and return the Expression.
lines | the Expression to compile |
profileMe | if true record the evaluation time |
JasmineException |
|
staticpackage |
Get the singleton instance.
|
private |
Parse an expression and return a list of tokens in infix order