Package org.camunda.bpm.impl.juel
Class Parser
java.lang.Object
org.camunda.bpm.impl.juel.Parser
Handcrafted top-down parser.
- Author:
- Christoph Beck
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Provide limited support for syntax extensions.static enum
static class
Parse exception type -
Field Summary
Modifier and TypeFieldDescriptionprotected final Builder
protected Map<Scanner.ExtensionToken,
Parser.ExtensionHandler> protected final Scanner
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected 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 final Scanner.Token
consume current token (get next token).protected final 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
throw exceptionprotected void
fail
(Scanner.Symbol expected) throw exceptionprotected final AstFunction
function
(String name, AstParameters params) protected Parser.ExtensionHandler
getExtensionHandler
(Scanner.Token token) protected final List<FunctionNode>
protected final List<IdentifierNode>
protected final Scanner.Token
getToken()
protected final AstIdentifier
identifier
(String name) protected AstNode
literal()
literal := <TRUE> | <FALSE> | <STRING> | <INTEGER> | <FLOAT> | <NULL>protected final Scanner.Token
lookahead
(int index) get lookahead symbol.protected AstNode
mul
(boolean required) mul := unary (<MUL> unary | <DIV> unary | <MOD> unary)*protected AstNode
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 := 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 Details
-
context
-
scanner
-
extensions
-
-
Constructor Details
-
Parser
-
-
Method Details
-
createScanner
-
putExtensionHandler
-
getExtensionHandler
-
parseInteger
Parse an integer literal.- Parameters:
string
- string to parse- Returns:
Long.valueOf(string)
- Throws:
Parser.ParseException
-
parseFloat
Parse a floating point literal.- Parameters:
string
- string to parse- Returns:
Double.valueOf(string)
- Throws:
Parser.ParseException
-
createAstBinary
-
createAstBracket
protected AstBracket createAstBracket(AstNode base, AstNode property, boolean lvalue, boolean strict) -
createAstChoice
-
createAstComposite
-
createAstDot
-
createAstFunction
-
createAstIdentifier
-
createAstMethod
-
createAstUnary
-
getFunctions
-
getIdentifiers
-
getToken
-
fail
throw exception- Throws:
Parser.ParseException
-
fail
throw exception- Throws:
Parser.ParseException
-
lookahead
protected final Scanner.Token lookahead(int index) throws Scanner.ScanException, Parser.ParseException get lookahead symbol. -
consumeToken
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
tree := text? ((dynamic text?)+ | (deferred text?)+)? -
text
text := <TEXT> -
eval
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
expr := or (<QUESTION> expr <COLON> expr)? -
or
or := and (<OR> and)* -
and
and := eq (<AND> eq)* -
eq
eq := cmp (<EQ> cmp | <NE> cmp)* -
cmp
cmp := add (<LT> add | <LE> add | <GE> add | <GT> add)* -
add
add := add (<PLUS> mul | <MINUS> mul)* -
mul
mul := unary (<MUL> unary | <DIV> unary | <MOD> unary)* -
unary
unary := <NOT> unary | <MINUS> unary | <EMPTY> unary | value -
value
value := (nonliteral | literal) (<DOT> <IDENTIFIER> | <LBRACK> expr <RBRACK>)* -
nonliteral
nonliteral := <IDENTIFIER> | function | <LPAREN> expr <RPAREN> function := (<IDENTIFIER> <COLON>)? <IDENTIFIER> <LPAREN> list? <RPAREN> -
params
params := <LPAREN> (expr (<COMMA> expr)*)? <RPAREN> -
literal
literal := <TRUE> | <FALSE> | <STRING> | <INTEGER> | <FLOAT> | <NULL> -
function
-
identifier
-