use of com.google.auto.value.processor.escapevelocity.TokenNode.ForEachTokenNode 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);
}
}
use of com.google.auto.value.processor.escapevelocity.TokenNode.ForEachTokenNode in project auto by google.
the class Parser method parseForEach.
/**
* Parses a {@code #foreach} token from the reader. <pre>{@code
* <foreach-token> -> #foreach ( $<id> in <expression> )
* }</pre>
*/
private Node parseForEach() throws IOException {
expect('(');
expect('$');
String var = parseId("For-each variable");
skipSpace();
boolean bad = false;
if (c != 'i') {
bad = true;
} else {
next();
if (c != 'n') {
bad = true;
}
}
if (bad) {
throw parseException("Expected 'in' for #foreach");
}
next();
ExpressionNode collection = parseExpression();
expect(')');
return new ForEachTokenNode(var, collection);
}
use of com.google.auto.value.processor.escapevelocity.TokenNode.ForEachTokenNode in project auto by google.
the class Reparser method parseForEach.
private Node parseForEach(ForEachTokenNode forEach) {
Node body = parseTo(END_SET, forEach);
// Skip #end
nextNode();
return new ForEachNode(forEach.lineNumber, forEach.var, forEach.collection, body);
}
Aggregations