Package org.camunda.bpm.engine.impl.juel
Class Parser
- java.lang.Object
-
- org.camunda.bpm.engine.impl.juel.Parser
-
public class Parser extends java.lang.Object
Handcrafted top-down parser.- Author:
- Christoph Beck
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Parser.ExtensionHandler
Provide limited support for syntax extensions.static class
Parser.ExtensionPoint
static class
Parser.ParseException
Parse exception type
-
Field Summary
Fields Modifier and Type Field Description protected Builder
context
protected java.util.Map<Scanner.ExtensionToken,Parser.ExtensionHandler>
extensions
protected Scanner
scanner
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected AstNode
add(boolean required)
add := add (<PLUS> mul | <MINUS> mul)*protected AstNode
and(boolean required)
and := eq (<AND> eq)*protected AstNode
cmp(boolean required)
cmp := add (<LT> add | <LE> add | <GE> add | <GT> add)*protected Scanner.Token
consumeToken()
consume current token (get next token).protected Scanner.Token
consumeToken(Scanner.Symbol expected)
consume current token (get next token); throw exception if the current token doesn't match the expected symbol.protected AstBinary
createAstBinary(AstNode left, AstNode right, AstBinary.Operator operator)
protected AstBracket
createAstBracket(AstNode base, AstNode property, boolean lvalue, boolean strict)
protected AstChoice
createAstChoice(AstNode question, AstNode yes, AstNode no)
protected AstComposite
createAstComposite(java.util.List<AstNode> nodes)
protected AstDot
createAstDot(AstNode base, java.lang.String property, boolean lvalue)
protected AstFunction
createAstFunction(java.lang.String name, int index, AstParameters params)
protected AstIdentifier
createAstIdentifier(java.lang.String name, int index)
protected AstMethod
createAstMethod(AstProperty property, AstParameters params)
protected AstUnary
createAstUnary(AstNode child, AstUnary.Operator operator)
protected Scanner
createScanner(java.lang.String expression)
protected AstNode
eq(boolean required)
eq := cmp (<EQ> cmp | <NE> cmp)*protected AstEval
eval()
eval := dynamic | deferredprotected AstEval
eval(boolean required, boolean deferred)
dynmamic := <START_EVAL_DYNAMIC> expr <END_EVAL> deferred := <START_EVAL_DEFERRED> expr <END_EVAL>protected AstNode
expr(boolean required)
expr := or (<QUESTION> expr <COLON> expr)?protected void
fail(java.lang.String expected)
throw exceptionprotected void
fail(Scanner.Symbol expected)
throw exceptionprotected AstFunction
function(java.lang.String name, AstParameters params)
protected Parser.ExtensionHandler
getExtensionHandler(Scanner.Token token)
protected java.util.List<FunctionNode>
getFunctions()
protected java.util.List<IdentifierNode>
getIdentifiers()
protected Scanner.Token
getToken()
protected AstIdentifier
identifier(java.lang.String name)
protected AstNode
literal()
literal := <TRUE> | <FALSE> | <STRING> | <INTEGER> | <FLOAT> | <NULL>protected Scanner.Token
lookahead(int index)
get lookahead symbol.protected AstNode
mul(boolean required)
mul := unary (<MUL> unary | <DIV> unary | <MOD> unary)*protected AstNode
nonliteral()
nonliteral := <IDENTIFIER> | function | <LPAREN> expr <RPAREN> function := (<IDENTIFIER> <COLON>)? <IDENTIFIER> <LPAREN> list? <RPAREN>protected AstNode
or(boolean required)
or := and (<OR> and)*protected AstParameters
params()
params := <LPAREN> (expr (<COMMA> expr)*)? <RPAREN>protected java.lang.Number
parseFloat(java.lang.String string)
Parse a floating point literal.protected java.lang.Number
parseInteger(java.lang.String string)
Parse an integer literal.void
putExtensionHandler(Scanner.ExtensionToken token, Parser.ExtensionHandler extension)
protected AstNode
text()
text := <TEXT>Tree
tree()
tree := text? ((dynamic text?)+ | (deferred text?)+)?protected AstNode
unary(boolean required)
unary := <NOT> unary | <MINUS> unary | <EMPTY> unary | valueprotected AstNode
value()
value := (nonliteral | literal) (<DOT> <IDENTIFIER> | <LBRACK> expr <RBRACK>)*
-
-
-
Field Detail
-
context
protected final Builder context
-
scanner
protected final Scanner scanner
-
extensions
protected java.util.Map<Scanner.ExtensionToken,Parser.ExtensionHandler> extensions
-
-
Constructor Detail
-
Parser
public Parser(Builder context, java.lang.String input)
-
-
Method Detail
-
createScanner
protected Scanner createScanner(java.lang.String expression)
-
putExtensionHandler
public void putExtensionHandler(Scanner.ExtensionToken token, Parser.ExtensionHandler extension)
-
getExtensionHandler
protected Parser.ExtensionHandler getExtensionHandler(Scanner.Token token)
-
parseInteger
protected java.lang.Number parseInteger(java.lang.String string) throws Parser.ParseException
Parse an integer literal.- Parameters:
string
- string to parse- Returns:
Long.valueOf(string)
- Throws:
Parser.ParseException
-
parseFloat
protected java.lang.Number parseFloat(java.lang.String string) throws Parser.ParseException
Parse a floating point literal.- Parameters:
string
- string to parse- Returns:
Double.valueOf(string)
- Throws:
Parser.ParseException
-
createAstBinary
protected AstBinary createAstBinary(AstNode left, AstNode right, AstBinary.Operator operator)
-
createAstBracket
protected AstBracket createAstBracket(AstNode base, AstNode property, boolean lvalue, boolean strict)
-
createAstComposite
protected AstComposite createAstComposite(java.util.List<AstNode> nodes)
-
createAstDot
protected AstDot createAstDot(AstNode base, java.lang.String property, boolean lvalue)
-
createAstFunction
protected AstFunction createAstFunction(java.lang.String name, int index, AstParameters params)
-
createAstIdentifier
protected AstIdentifier createAstIdentifier(java.lang.String name, int index)
-
createAstMethod
protected AstMethod createAstMethod(AstProperty property, AstParameters params)
-
createAstUnary
protected AstUnary createAstUnary(AstNode child, AstUnary.Operator operator)
-
getFunctions
protected final java.util.List<FunctionNode> getFunctions()
-
getIdentifiers
protected final java.util.List<IdentifierNode> getIdentifiers()
-
getToken
protected final Scanner.Token getToken()
-
fail
protected void fail(java.lang.String expected) throws Parser.ParseException
throw exception- Throws:
Parser.ParseException
-
fail
protected void fail(Scanner.Symbol expected) throws Parser.ParseException
throw exception- Throws:
Parser.ParseException
-
lookahead
protected final Scanner.Token lookahead(int index) throws Scanner.ScanException, Parser.ParseException
get lookahead symbol.
-
consumeToken
protected final Scanner.Token consumeToken() throws Scanner.ScanException, Parser.ParseException
consume current token (get next token).- Returns:
- the consumed token (which was the current token when calling this method)
- Throws:
Scanner.ScanException
Parser.ParseException
-
consumeToken
protected final Scanner.Token consumeToken(Scanner.Symbol expected) throws Scanner.ScanException, Parser.ParseException
consume current token (get next token); throw exception if the current token doesn't match the expected symbol.
-
tree
public Tree tree() throws Scanner.ScanException, Parser.ParseException
tree := text? ((dynamic text?)+ | (deferred text?)+)?
-
text
protected AstNode text() throws Scanner.ScanException, Parser.ParseException
text := <TEXT>
-
eval
protected AstEval eval() throws Scanner.ScanException, Parser.ParseException
eval := dynamic | deferred
-
eval
protected AstEval eval(boolean required, boolean deferred) throws Scanner.ScanException, Parser.ParseException
dynmamic := <START_EVAL_DYNAMIC> expr <END_EVAL> deferred := <START_EVAL_DEFERRED> expr <END_EVAL>
-
expr
protected AstNode expr(boolean required) throws Scanner.ScanException, Parser.ParseException
expr := or (<QUESTION> expr <COLON> expr)?
-
or
protected AstNode or(boolean required) throws Scanner.ScanException, Parser.ParseException
or := and (<OR> and)*
-
and
protected AstNode and(boolean required) throws Scanner.ScanException, Parser.ParseException
and := eq (<AND> eq)*
-
eq
protected AstNode eq(boolean required) throws Scanner.ScanException, Parser.ParseException
eq := cmp (<EQ> cmp | <NE> cmp)*
-
cmp
protected AstNode cmp(boolean required) throws Scanner.ScanException, Parser.ParseException
cmp := add (<LT> add | <LE> add | <GE> add | <GT> add)*
-
add
protected AstNode add(boolean required) throws Scanner.ScanException, Parser.ParseException
add := add (<PLUS> mul | <MINUS> mul)*
-
mul
protected AstNode mul(boolean required) throws Scanner.ScanException, Parser.ParseException
mul := unary (<MUL> unary | <DIV> unary | <MOD> unary)*
-
unary
protected AstNode unary(boolean required) throws Scanner.ScanException, Parser.ParseException
unary := <NOT> unary | <MINUS> unary | <EMPTY> unary | value
-
value
protected AstNode value() throws Scanner.ScanException, Parser.ParseException
value := (nonliteral | literal) (<DOT> <IDENTIFIER> | <LBRACK> expr <RBRACK>)*
-
nonliteral
protected AstNode nonliteral() throws Scanner.ScanException, Parser.ParseException
nonliteral := <IDENTIFIER> | function | <LPAREN> expr <RPAREN> function := (<IDENTIFIER> <COLON>)? <IDENTIFIER> <LPAREN> list? <RPAREN>
-
params
protected AstParameters params() throws Scanner.ScanException, Parser.ParseException
params := <LPAREN> (expr (<COMMA> expr)*)? <RPAREN>
-
literal
protected AstNode literal() throws Scanner.ScanException, Parser.ParseException
literal := <TRUE> | <FALSE> | <STRING> | <INTEGER> | <FLOAT> | <NULL>
-
function
protected final AstFunction function(java.lang.String name, AstParameters params)
-
identifier
protected final AstIdentifier identifier(java.lang.String name)
-
-