public class Parser extends Object
Modifier and Type | Class and Description |
---|---|
static class |
Parser.ExtensionHandler
Provide limited support for syntax extensions.
|
static class |
Parser.ExtensionPoint |
static class |
Parser.ParseException
Parse exception type
|
Modifier and Type | Field and Description |
---|---|
protected Builder |
context |
protected Map<Scanner.ExtensionToken,Parser.ExtensionHandler> |
extensions |
protected Scanner |
scanner |
Modifier and Type | Method and 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 | 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>)*
|
protected final Builder context
protected final Scanner scanner
protected Map<Scanner.ExtensionToken,Parser.ExtensionHandler> extensions
public void putExtensionHandler(Scanner.ExtensionToken token, Parser.ExtensionHandler extension)
protected Parser.ExtensionHandler getExtensionHandler(Scanner.Token token)
protected Number parseInteger(String string) throws Parser.ParseException
string
- string to parseLong.valueOf(string)
Parser.ParseException
protected Number parseFloat(String string) throws Parser.ParseException
string
- string to parseDouble.valueOf(string)
Parser.ParseException
protected AstBinary createAstBinary(AstNode left, AstNode right, AstBinary.Operator operator)
protected AstBracket createAstBracket(AstNode base, AstNode property, boolean lvalue, boolean strict)
protected AstComposite createAstComposite(List<AstNode> nodes)
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 final List<FunctionNode> getFunctions()
protected final List<IdentifierNode> getIdentifiers()
protected final Scanner.Token getToken()
protected void fail(String expected) throws Parser.ParseException
Parser.ParseException
protected void fail(Scanner.Symbol expected) throws Parser.ParseException
Parser.ParseException
protected final Scanner.Token lookahead(int index) throws Scanner.ScanException, Parser.ParseException
protected final Scanner.Token consumeToken() throws Scanner.ScanException, Parser.ParseException
Scanner.ScanException
Parser.ParseException
protected final Scanner.Token consumeToken(Scanner.Symbol expected) throws Scanner.ScanException, Parser.ParseException
public Tree tree() throws Scanner.ScanException, Parser.ParseException
protected AstNode text() throws Scanner.ScanException, Parser.ParseException
protected AstEval eval() throws Scanner.ScanException, Parser.ParseException
protected AstEval eval(boolean required, boolean deferred) throws Scanner.ScanException, Parser.ParseException
protected AstNode expr(boolean required) throws Scanner.ScanException, Parser.ParseException
protected AstNode or(boolean required) throws Scanner.ScanException, Parser.ParseException
protected AstNode and(boolean required) throws Scanner.ScanException, Parser.ParseException
protected AstNode eq(boolean required) throws Scanner.ScanException, Parser.ParseException
protected AstNode cmp(boolean required) throws Scanner.ScanException, Parser.ParseException
protected AstNode add(boolean required) throws Scanner.ScanException, Parser.ParseException
protected AstNode mul(boolean required) throws Scanner.ScanException, Parser.ParseException
protected AstNode unary(boolean required) throws Scanner.ScanException, Parser.ParseException
protected AstNode value() throws Scanner.ScanException, Parser.ParseException
protected AstNode nonliteral() throws Scanner.ScanException, Parser.ParseException
protected AstParameters params() throws Scanner.ScanException, Parser.ParseException
protected AstNode literal() throws Scanner.ScanException, Parser.ParseException
protected final AstFunction function(String name, AstParameters params)
protected final AstIdentifier identifier(String name)
Copyright © 2019. All rights reserved.