jsynoptic.parser
Class ExpressionParser
java.lang.Object
jsynoptic.parser.ExpressionParser
- All Implemented Interfaces:
- ExpressionParserConstants, ExpressionParserTreeConstants
public class ExpressionParser
- extends java.lang.Object
- implements ExpressionParserTreeConstants, ExpressionParserConstants
Fields inherited from interface jsynoptic.parser.ExpressionParserTreeConstants |
JJTADDITION, JJTBOOLEANTEST, JJTFUNCTIONCALL, JJTLOGICALOPERATION, JJTMULTIPLICATION, jjtNodeName, JJTNUMBER, JJTPOWER, JJTUNARYOPERATION, JJTUNARYOPERATOR, JJTVOID |
Fields inherited from interface jsynoptic.parser.ExpressionParserConstants |
ALPHANUM, BLANK, DEC, DEFAULT, DOUBLEQUOTE, EOF, HEX, IDENTIFIER, LOGICAL_OPERATOR, NINT, NUMBER, SCI, SINGLEQUOTE, tokenImage, ZINT |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
jjtree
protected jsynoptic.parser.JJTExpressionParserState jjtree
variables
protected java.util.Vector variables
- The mechanism to decide between functions or variables is as follow :
We maintain a list of variables : this is a java.util.Vector of objects implementing
the Variable interface. The variable name is matched at parse time.
A vector of Class is also maintained. Introspection is done at parse time,
to check the function name in the expression with public static functions
in these classes. The signature must also be compatible with the expression
(ex: number of arguments). By default java.lang.Math is included in the vector, but
of course you may add more user-defined classes.
Once parsed, the Node for the function call will keep the reference of the variable
or class method. Thus the expression evaluation is quite fast and does not use
introspection at all.
classes
protected java.util.Vector classes
methods
protected java.util.Vector methods
token_source
public ExpressionParserTokenManager token_source
token
public Token token
jj_nt
public Token jj_nt
lookingAhead
public boolean lookingAhead
ExpressionParser
public ExpressionParser(java.lang.String s)
- Utility shortcut for parsing strings => just wrap in an StreamReader
ExpressionParser
public ExpressionParser(java.io.InputStream stream)
ExpressionParser
public ExpressionParser(java.io.Reader stream)
ExpressionParser
public ExpressionParser(ExpressionParserTokenManager tm)
addVariable
public void addVariable(VariableDefinition v)
removeVariable
public void removeVariable(VariableDefinition v)
variableIterator
public java.util.Iterator variableIterator()
addClass
public void addClass(java.lang.Class c)
removeClass
public void removeClass(java.lang.Class c)
classesIterator
public java.util.Iterator classesIterator()
lookupMethods
protected void lookupMethods(java.lang.Class c)
- Utility function to lookup the methods of the given class and
add them to the method cache.
parse
public ExpressionNode parse()
throws ParseException
- External call non-static API => returns the root node of the parse tree
- Throws:
ParseException
main
public static void main(java.lang.String[] args)
Expression
public final void Expression()
throws ParseException
- Throws:
ParseException
LogicalOperation
public final void LogicalOperation()
throws ParseException
- Throws:
ParseException
BooleanTest
public final void BooleanTest()
throws ParseException
- Throws:
ParseException
Addition
public final void Addition()
throws ParseException
- Throws:
ParseException
Multiplication
public final void Multiplication()
throws ParseException
- Throws:
ParseException
UnaryOperation
public final void UnaryOperation()
throws ParseException
- Throws:
ParseException
UnaryOperator
public final void UnaryOperator()
throws ParseException
- Throws:
ParseException
Power
public final void Power()
throws ParseException
- Throws:
ParseException
MonoBlock
public final void MonoBlock()
throws ParseException
- Throws:
ParseException
Number
public final void Number()
throws ParseException
- Throws:
ParseException
FunctionCall
public final void FunctionCall()
throws ParseException
- Throws:
ParseException
ReInit
public void ReInit(java.io.InputStream stream)
ReInit
public void ReInit(java.io.Reader stream)
ReInit
public void ReInit(ExpressionParserTokenManager tm)
getNextToken
public final Token getNextToken()
getToken
public final Token getToken(int index)
generateParseException
public ParseException generateParseException()
enable_tracing
public final void enable_tracing()
disable_tracing
public final void disable_tracing()