Package org.vedantatree.expressionoasis
Class Parser
- java.lang.Object
-
- org.vedantatree.expressionoasis.Parser
-
public final class Parser extends Object
This parser object parses the expressions, break these in expression tokens and perform lexical analysis on these tokens. All kind of expressions can be parsed like arithmetic, function call, and property accessor etc. By default, it ignores the extra blanks.
Some examples of expression
1). 123 + 124 - 67 * 45 div 90 + (12 + 34 div 67) .
2). principal * pow(( 1 - rate div 100 ), time) .
3). 120 * pow(sin(20) div tan(30), 2) .
4). values[0] + values[1] + values[2] + 120 * 45 div num[1][1] .
5). person.address.city.name + students[0].rollNo .
6). /person/address/city/name + /person/children[name='Ram'] + /person/children[1] .
7). abc=xyz || 1!=2 && 3 >= xyz && xvz <= 30 .
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static void
main(String[] args)
List<ExpressionToken>
parse(String expression)
It parses the given expression string into ExpressionToken objects and returns the list of ExpressionTokens.
-
-
-
Constructor Detail
-
Parser
public Parser()
Deprecated.seems of no use, since Parser is always created from Compiler with Grammar instanceConstructs the Parser with default DefaultXMLGrammar instance
-
Parser
public Parser(Grammar grammar)
Constructs the Parser with given DefaultXMLGrammar object- Parameters:
grammar
- the grammar using which it parse the expression.- Throws:
IllegalArgumentException
- if the grammar is null.
-
-
Method Detail
-
parse
public final List<ExpressionToken> parse(String expression) throws ExpressionEngineException
It parses the given expression string into ExpressionToken objects and returns the list of ExpressionTokens.- Parameters:
expression
- the expression string to parse- Returns:
- list of ExpressionToken
- Throws:
ExpressionEngineException
- if unable to parseIllegalArgumentException
- if the expression is not a qualified string
-
main
public static void main(String[] args) throws ExpressionEngineException
- Throws:
ExpressionEngineException
-
-