|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.peaseplate.internal.lang.Parser
public class Parser
The default parser for the referece language. Default Reference = Command Key = KeyIdentifier | String Identifier = Identifier Command = ("(" Command ")" ) | (Expression {AnyOperator Command} ["?" Command ":" Command] TransformerChain) Expression = [UnaryOperator] (Invocation | Query | Variable | Number | String | "true" | "false" | "null" | "$this" | "$pop") {ExpressionChain} ExpressionChain = Query | ("." ("$pop" | Invocation)) Invocation = Identifier ParameterList Query = "[" Command "]" ParameterList ParameterList = ["(" {Command {"," Command}} ")"] VariableList = ["(" {Variable {"," Variable}} ")"] IdentifierList = ["(" {Identifier {"," Identifier}} ")"] TransformerChain = {"->" Identifier ["." Identifier] ParameterList} IdentifierExtension = ["." Identifier] AnyOperator = MultiplicativeOperator | AdditiveOperator | ShiftOperator | RelationalOperator | EqualityOperator | BitwiseOperator | ConditionalAndOperator | ConditionalOrOperator UnaryOperator = "+" | "-" | "~" | "!" MultiplicativeOperator = "*" | "/" | "%" AdditiveOperator = "+" | "-" ShiftOperator = "<<" | ">>" | ">>>" RelationalOperator = "<" | "<=" | ">" | ">=" EqualityOperator = "==" | "!=" BitwiseOperator = "&" | "^" | "|" ConditionalAndOperator = "&&" ConditionalOrOperator = "||" Identifier = (LETTER | "_") {LETTER | DIGIT | "_"} Variable = '$' (LETTER | DIGIT | "_") {LETTER | DIGIT | "_"} KeyIdentifier = (LETTER | DIGIT | "_" | "-" | "." | "/") {LETTER | DIGIT | "_" | "-" | "." | "/"} AnyIdentifier = ANY_EXCEPT_SPACE Number = (DecimalNumber | RealNumber | HexNumber | OctalNumber) DecimalNumber = DIGIT_EXCEPT_ZERO {DIGIT} RealNumber = {DIGIT} ["." DIGIT {DIGIT}] [("e" | "E") ["-" | "+"] DIGIT {DIGIT}] ["d" | "D" | "f" | "F"] HexNumber = ("#" | "0x") DIGIT {DIGIT} OctalNumber = "0" {DIGIT} String = "\"" {ANY_EXCEPT_QUOTES} "\"" Boolean = "true" | "false" Keyword = "pop" | "this" Null = "null"
Constructor Summary | |
---|---|
Parser(TemplateEngine engine,
CompileContext context,
int line,
int column,
char[] code,
int offset,
int length)
|
Method Summary | |
---|---|
protected ICommand |
createDoubleParameterCommand(Tokenizer.Type operator,
java.lang.Object value,
int line,
int column,
ICommand left,
ICommand right)
|
protected ICommand |
createSingleParameterCommand(Tokenizer.Type operator,
java.lang.Object value,
int line,
int column,
ICommand command)
|
CompileContext |
getContext()
|
TemplateEngine |
getEngine()
|
Tokenizer |
getTokenizer()
|
protected boolean |
isAnyOperator()
|
protected boolean |
isAnyOperator(Tokenizer.Type type)
|
protected boolean |
isExpression()
|
protected boolean |
isExpressionChain()
|
protected boolean |
isInvocation()
|
java.lang.String |
parseAssignedKey()
|
protected ICommand |
parseCommand(Tokenizer.Type operator,
int parenthesisCount)
Parses the command notation Command = ("(" Command ")" ) | (Expression {AnyOperator Command} ["?" |
protected ICommand |
parseExpression()
Parses the expression. |
protected ICommand |
parseExpressionChain(ICommand command)
|
java.lang.String |
parseIdentifierExtension()
Parses the code as identifier extension. |
java.lang.String[] |
parseIdentifierList()
Parses the code as identifier list. |
protected ICommand |
parseInvocation(ICommand command)
|
ICommand[] |
parseParameterList()
Parses the code as parameter list. |
protected ICommand |
parseQuery(ICommand command)
|
protected ICommand |
parseSubExpression()
|
ICommand |
parseTransformerChain(ICommand command)
Parses the transformer notation. |
java.lang.String[] |
parseVariableList()
Parses the code as variable list. |
ICommand |
readDefaultReference()
Parses the code as default reference. |
java.lang.String |
readIdentifier()
Parses the code as a single identifier. |
java.lang.String |
readKey()
Parses the code as key token. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Parser(TemplateEngine engine, CompileContext context, int line, int column, char[] code, int offset, int length)
Method Detail |
---|
public TemplateEngine getEngine()
public CompileContext getContext()
public Tokenizer getTokenizer()
public ICommand readDefaultReference() throws TemplateException
TemplateException
- on occasionpublic java.lang.String readKey() throws TemplateException
TemplateException
- on occasionpublic java.lang.String readIdentifier() throws TemplateException
TemplateException
- on occasionprotected ICommand parseCommand(Tokenizer.Type operator, int parenthesisCount) throws TemplateException
operator
- the operator just prior to the current tokenparenthesisCount
- the count of parentheses
TemplateException
- on occasionprotected boolean isAnyOperator() throws TemplateException
TemplateException
protected boolean isExpression()
protected ICommand parseExpression() throws TemplateException
TemplateException
- on occasionprotected ICommand parseSubExpression() throws TemplateException
TemplateException
protected boolean isExpressionChain()
protected ICommand parseExpressionChain(ICommand command) throws TemplateException
TemplateException
protected boolean isInvocation()
protected ICommand parseInvocation(ICommand command) throws TemplateException
TemplateException
protected ICommand parseQuery(ICommand command) throws TemplateException
TemplateException
public ICommand[] parseParameterList() throws TemplateException
TemplateException
- on occasionpublic java.lang.String[] parseVariableList() throws TemplateException
TemplateException
- on occasionpublic java.lang.String[] parseIdentifierList() throws TemplateException
TemplateException
- on occasionpublic java.lang.String parseIdentifierExtension() throws TemplateException
TemplateException
protected ICommand createSingleParameterCommand(Tokenizer.Type operator, java.lang.Object value, int line, int column, ICommand command) throws TemplateException
TemplateException
protected ICommand createDoubleParameterCommand(Tokenizer.Type operator, java.lang.Object value, int line, int column, ICommand left, ICommand right) throws TemplateException
TemplateException
public ICommand parseTransformerChain(ICommand command) throws TemplateException
command
- the command to be sent to the transformer
TemplateException
- on occasionpublic java.lang.String parseAssignedKey() throws TemplateException
TemplateException
protected boolean isAnyOperator(Tokenizer.Type type)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |