Package org.camunda.bpm.engine.impl.juel
Class Parser
- java.lang.Object
-
- org.camunda.bpm.engine.impl.juel.Parser
-
public class Parser extends 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 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(List<AstNode> nodes)
protected AstDot
createAstDot(AstNode base, String property, boolean lvalue)
protected AstFunction
createAstFunction(String name, int index, AstParameters params)
protected AstIdentifier
createAstIdentifier(String name, int index)
protected AstMethod
createAstMethod(AstProperty property, AstParameters params)
protected AstUnary
createAstUnary(AstNode child, AstUnary.Operator operator)
protected Scanner
createScanner(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(String expected)
throw exceptionprotected void
fail(Scanner.Symbol expected)
throw exceptionprotected AstFunction
function(String name, AstParameters params)
protected Parser.ExtensionHandler
getExtensionHandler(Scanner.Token token)
protected List<FunctionNode>
getFunctions()
protected List<IdentifierNode>
getIdentifiers()
protected Scanner.Token
getToken()
protected AstIdentifier
identifier(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 Number
parseFloat(String string)
Parse a floating point literal.protected Number
parseInteger(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 Map<Scanner.ExtensionToken,Parser.ExtensionHandler> extensions
-
-
Method Detail
-
putExtensionHandler
public void putExtensionHandler(Scanner.ExtensionToken token, Parser.ExtensionHandler extension)
-
getExtensionHandler
protected Parser.ExtensionHandler getExtensionHandler(Scanner.Token token)
-
parseInteger
protected Number parseInteger(String string) throws Parser.ParseException
Parse an integer literal.- Parameters:
string
- string to parse- Returns:
Long.valueOf(string)
- Throws:
Parser.ParseException
-
parseFloat
protected Number parseFloat(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(List<AstNode> nodes)
-
createAstFunction
protected AstFunction createAstFunction(String name, int index, AstParameters params)
-
createAstIdentifier
protected AstIdentifier createAstIdentifier(String name, int index)
-
createAstMethod
protected AstMethod createAstMethod(AstProperty property, AstParameters params)
-
createAstUnary
protected AstUnary createAstUnary(AstNode child, AstUnary.Operator operator)
-
getFunctions
protected final List<FunctionNode> getFunctions()
-
getIdentifiers
protected final List<IdentifierNode> getIdentifiers()
-
getToken
protected final Scanner.Token getToken()
-
fail
protected void fail(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(String name, AstParameters params)
-
identifier
protected final AstIdentifier identifier(String name)
-
-