org.camunda.bpm.engine.impl.juel
Class Parser

java.lang.Object
  extended by org.camunda.bpm.engine.impl.juel.Parser

public class Parser
extends Object

Handcrafted top-down parser.

Author:
Christoph Beck

Nested Class Summary
static class Parser.ExtensionHandler
          Provide limited support for syntax extensions.
static class Parser.ExtensionPoint
           
static class Parser.ParseException
          Parse exception type
 
Field Summary
protected  Builder context
           
protected  Map<Scanner.ExtensionToken,Parser.ExtensionHandler> extensions
           
protected  Scanner scanner
           
 
Constructor Summary
Parser(Builder context, String input)
           
 
Method Summary
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 | deferred
protected  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(Scanner.Symbol expected)
          throw exception
protected  void fail(String expected)
          throw exception
protected  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 | value
protected  AstNode value()
          value := (nonliteral | literal) (<DOT> <IDENTIFIER> | <LBRACK> expr <RBRACK>)*
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected final Builder context

scanner

protected final Scanner scanner

extensions

protected Map<Scanner.ExtensionToken,Parser.ExtensionHandler> extensions
Constructor Detail

Parser

public Parser(Builder context,
              String input)
Method Detail

createScanner

protected Scanner createScanner(String expression)

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)

createAstChoice

protected AstChoice createAstChoice(AstNode question,
                                    AstNode yes,
                                    AstNode no)

createAstComposite

protected AstComposite createAstComposite(List<AstNode> nodes)

createAstDot

protected AstDot createAstDot(AstNode base,
                              String property,
                              boolean lvalue)

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.

Throws:
Scanner.ScanException
Parser.ParseException

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.

Throws:
Scanner.ScanException
Parser.ParseException

tree

public Tree tree()
          throws Scanner.ScanException,
                 Parser.ParseException
tree := text? ((dynamic text?)+ | (deferred text?)+)?

Throws:
Scanner.ScanException
Parser.ParseException

text

protected AstNode text()
                throws Scanner.ScanException,
                       Parser.ParseException
text := <TEXT>

Throws:
Scanner.ScanException
Parser.ParseException

eval

protected AstEval eval()
                throws Scanner.ScanException,
                       Parser.ParseException
eval := dynamic | deferred

Throws:
Scanner.ScanException
Parser.ParseException

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>

Throws:
Scanner.ScanException
Parser.ParseException

expr

protected AstNode expr(boolean required)
                throws Scanner.ScanException,
                       Parser.ParseException
expr := or (<QUESTION> expr <COLON> expr)?

Throws:
Scanner.ScanException
Parser.ParseException

or

protected AstNode or(boolean required)
              throws Scanner.ScanException,
                     Parser.ParseException
or := and (<OR> and)*

Throws:
Scanner.ScanException
Parser.ParseException

and

protected AstNode and(boolean required)
               throws Scanner.ScanException,
                      Parser.ParseException
and := eq (<AND> eq)*

Throws:
Scanner.ScanException
Parser.ParseException

eq

protected AstNode eq(boolean required)
              throws Scanner.ScanException,
                     Parser.ParseException
eq := cmp (<EQ> cmp | <NE> cmp)*

Throws:
Scanner.ScanException
Parser.ParseException

cmp

protected AstNode cmp(boolean required)
               throws Scanner.ScanException,
                      Parser.ParseException
cmp := add (<LT> add | <LE> add | <GE> add | <GT> add)*

Throws:
Scanner.ScanException
Parser.ParseException

add

protected AstNode add(boolean required)
               throws Scanner.ScanException,
                      Parser.ParseException
add := add (<PLUS> mul | <MINUS> mul)*

Throws:
Scanner.ScanException
Parser.ParseException

mul

protected AstNode mul(boolean required)
               throws Scanner.ScanException,
                      Parser.ParseException
mul := unary (<MUL> unary | <DIV> unary | <MOD> unary)*

Throws:
Scanner.ScanException
Parser.ParseException

unary

protected AstNode unary(boolean required)
                 throws Scanner.ScanException,
                        Parser.ParseException
unary := <NOT> unary | <MINUS> unary | <EMPTY> unary | value

Throws:
Scanner.ScanException
Parser.ParseException

value

protected AstNode value()
                 throws Scanner.ScanException,
                        Parser.ParseException
value := (nonliteral | literal) (<DOT> <IDENTIFIER> | <LBRACK> expr <RBRACK>)*

Throws:
Scanner.ScanException
Parser.ParseException

nonliteral

protected AstNode nonliteral()
                      throws Scanner.ScanException,
                             Parser.ParseException
nonliteral := <IDENTIFIER> | function | <LPAREN> expr <RPAREN> function := (<IDENTIFIER> <COLON>)? <IDENTIFIER> <LPAREN> list? <RPAREN>

Throws:
Scanner.ScanException
Parser.ParseException

params

protected AstParameters params()
                        throws Scanner.ScanException,
                               Parser.ParseException
params := <LPAREN> (expr (<COMMA> expr)*)? <RPAREN>

Throws:
Scanner.ScanException
Parser.ParseException

literal

protected AstNode literal()
                   throws Scanner.ScanException,
                          Parser.ParseException
literal := <TRUE> | <FALSE> | <STRING> | <INTEGER> | <FLOAT> | <NULL>

Throws:
Scanner.ScanException
Parser.ParseException

function

protected final AstFunction function(String name,
                                     AstParameters params)

identifier

protected final AstIdentifier identifier(String name)


Copyright © 2016 camunda services GmbH. All rights reserved.