public class StatementParser
extends java.lang.Object
Tag in a TagNode, and has the following pseudo-EBNF grammar:
expression = ["!"] notcond
notcond = andcond {"&&" andcond}
andcond = orcond {"||" orcond}
orcond =
comparator [("=="|"!="|"<"|"<="|">="|">") comparator]
comparator = ["+"|"-"] term {("+"|"-") term}
term = factor {("*" | "/") factor}
factor =
variable
| number
| literal
| "(" expression ")"
variable = identifier [func-call] ["[" expression "]"] ["." variable]
func-call = "." identifier "(" expression {"," expression} ")"
identifier = "any valid Java identifier"
number = "and valid Java number"
literal = """ anything """
The statement parser allows you to extract any sub-element from a string as well (for example, the ForTag wants to pull off it's arguments an identifier followed by the identifier "in" followed by a statement.
| Constructor and Description |
|---|
StatementParser(Tokenizer tokenizer) |
| Modifier and Type | Method and Description |
|---|---|
Identifier |
maybeParseIdentifier()
Tries to parse an identifier from the stream and returns it if we parsed it, otherwise returns null.
|
void |
parseEnd()
Parses the "end" of the statement.
|
Expression |
parseExpression() |
Identifier |
parseIdentifier() |
NumberLiteral |
parseNumber() |
StringLiteral |
parseString() |
public StatementParser(Tokenizer tokenizer)
public void parseEnd()
throws CarrotException
CarrotException - if we're not actually at the end of the statement.@Nullable public Identifier maybeParseIdentifier() throws CarrotException
Identifier we parsed, or null if we couldn't parse an identifier.CarrotException - if there's some error parsing the identifer.public Identifier parseIdentifier() throws CarrotException
CarrotExceptionpublic NumberLiteral parseNumber() throws CarrotException
CarrotExceptionpublic StringLiteral parseString() throws CarrotException
CarrotExceptionpublic Expression parseExpression() throws CarrotException
CarrotException