@Override public void process(Token token, BuilderState state, TemplateEnvironment environment) { switch (token.getTokenType()) { case TEXT: case LINE_BREAK: state.popParserState(); state.popNode(); state.setPendingToken(token); return; case IDENTIFIER: if (token.getTokenString().equals("else")) { state.popParserState(); state.pushParserState(IF_TAG_INLINE_CLOSE); state.popNode(); state.pushNode(new ElseModel(token)); state.pushNode(new ExpressionModel()); state.pushParserState(EXPRESSION_OPEN); return; } startSyntaxErrorMode(token, state); return; default: startSyntaxErrorMode(token, state); } }
@Override public void process(Token token, BuilderState state, TemplateEnvironment environment) { switch (token.getTokenType()) { case IDENTIFIER: case STRING_LITERAL: state.currentNode().appendChild(new IncludePathModel(token)); state.pushParserState(ARGUMENTS); state.pushNode(new ArgumentsModel()); return; default: startSyntaxErrorMode(token, state); } }
@Override public void process(Token token, BuilderState state, TemplateEnvironment environment) { switch (token.getTokenType()) { case TEXT: if (!token.getTokenString().isEmpty()) { state.currentNode().appendChild(new TextModel(token)); } return; case LINE_BREAK: state.currentNode().appendChild(new LineBreakModel()); return; case IDENTIFIER: switch (token.getTokenString()) { case "include": state.pushParserState(INCLUDE_TAG); state.pushNode(new IncludeModel(token)); return; case "if": state.pushParserState(IF_TAG); state.pushNode(new IfModel(token)); return; case "with": state.pushParserState(WITH_TAG); state.pushNode(new WithModel(token)); return; case "for": state.pushParserState(FOR_TAG); state.pushNode(new ForModel(token)); return; default: state.pushParserState(VARIABLE_TAG); state.pushNode(new VariableModel(token)); state.setPendingToken(token); return; } case SLASH: state.pushParserState(CLOSE_TAG_START); return; case STRING_LITERAL: case INTEGER_LITERAL: case DOUBLE_LITERAL: case PARENTHESIS_OPEN: case PLUS: case HYPHEN: state.pushParserState(VARIABLE_TAG); state.pushNode(new VariableModel(token)); state.setPendingToken(token); return; default: state.currentNode().appendChild(new SyntaxErrorModel(token)); } }
protected void startExpressionMode(Token token, BuilderState state) { state.setPendingToken(token); state.pushNode(new ExpressionModel()); state.pushParserState(EXPRESSION_OPEN); }