@Override public void process(Token token, BuilderState state, TemplateEnvironment environment) { switch (token.getTokenType()) { case PARENTHESIS_OPEN: state.currentNode().appendChild(new ParenthesisModel(token)); state.popParserState(); state.pushParserState(EXPRESSION_OPEN); return; case STRING_LITERAL: state.currentNode().appendChild(new StringLiteralModel(token)); state.popParserState(); state.pushParserState(EXPRESSION_VALUE); return; case INTEGER_LITERAL: state.currentNode().appendChild(new IntegerLiteralModel(token)); state.popParserState(); state.pushParserState(EXPRESSION_VALUE); return; case DOUBLE_LITERAL: state.currentNode().appendChild(new DoubleLiteralModel(token)); state.popParserState(); state.pushParserState(EXPRESSION_VALUE); return; case IDENTIFIER: state.currentNode().appendChild(new IdentifierModel(token)); state.popParserState(); state.pushParserState(EXPRESSION_VALUE); return; default: state.popParserState(); state.popNode(); state.setPendingToken(token); } }
@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)); } }
@Override public void process(Token token, BuilderState state, TemplateEnvironment environment) { switch (token.getTokenType()) { case TEXT: case LINE_BREAK: state.setPendingToken(token); state.popParserState(); return; default: state.currentNode().appendChild(new SyntaxErrorModel(token)); } }
@Override public void process(Token token, BuilderState state, TemplateEnvironment environment) { switch (token.getTokenType()) { case TEXT: case LINE_BREAK: breakTag(token, state); return; case IDENTIFIER: return; default: state.currentNode().appendChild(new SyntaxErrorModel(token)); } }
@Override public void process(Token token, BuilderState state, TemplateEnvironment environment) { switch (token.getTokenType()) { case IDENTIFIER: if (!(state.currentNode() instanceof TagModel)) { state.currentNode().appendChild(new UnexpectedCloseTagErrorModel(token)); return; } TagModel tag = (TagModel) state.currentNode(); if (!tag.isMatchCloseTag(token.getTokenString())) { state.currentNode().appendChild(new UnmatchedCloseTagErrorModel(token)); return; } state.popNode(); state.popParserState(); 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 PARENTHESIS_CLOSE: state.currentNode().appendChild(new ParenthesisModel(token)); state.popParserState(); state.pushParserState(EXPRESSION_NEXT); return; case PLUS: case HYPHEN: case SLASH: case MOD: case MULTIPLIER: state.currentNode().appendChild(new OperatorModel(token)); state.popParserState(); state.pushParserState(EXPRESSION_OPERATOR); return; default: state.popParserState(); state.popNode(); state.setPendingToken(token); } }