use of com.google.auto.value.processor.escapevelocity.TokenNode.IfTokenNode in project auto by google.
the class Parser method parseIfOrElseIf.
/**
* Parses the condition following {@code #if} or {@code #elseif}.
* <pre>{@code
* <if-token> -> #if ( <condition> )
* <elseif-token> -> #elseif ( <condition> )
* }</pre>
*
* @param directive either {@code "if"} or {@code "elseif"}.
*/
private Node parseIfOrElseIf(String directive) throws IOException {
expect('(');
ExpressionNode condition = parseExpression();
expect(')');
return directive.equals("if") ? new IfTokenNode(condition) : new ElseIfTokenNode(condition);
}
use of com.google.auto.value.processor.escapevelocity.TokenNode.IfTokenNode in project auto by google.
the class Reparser method parseTokenNode.
private Node parseTokenNode() {
TokenNode tokenNode = (TokenNode) currentNode();
nextNode();
if (tokenNode instanceof CommentTokenNode) {
return emptyNode(tokenNode.lineNumber);
} else if (tokenNode instanceof IfTokenNode) {
return parseIfOrElseIf((IfTokenNode) tokenNode);
} else if (tokenNode instanceof ForEachTokenNode) {
return parseForEach((ForEachTokenNode) tokenNode);
} else if (tokenNode instanceof MacroDefinitionTokenNode) {
return parseMacroDefinition((MacroDefinitionTokenNode) tokenNode);
} else {
throw new IllegalArgumentException("Unexpected token: " + tokenNode.name() + " on line " + tokenNode.lineNumber);
}
}
Aggregations