예제 #1
0
파일: ParserState.java 프로젝트: kr9ly/teit
 @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);
   }
 }
예제 #2
0
파일: ParserState.java 프로젝트: kr9ly/teit
 @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));
   }
 }
예제 #3
0
파일: ParserState.java 프로젝트: kr9ly/teit
 @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);
   }
 }
예제 #4
0
파일: ParserState.java 프로젝트: kr9ly/teit
 @Override
 public void process(Token token, BuilderState state, TemplateEnvironment environment) {
   switch (token.getTokenType()) {
     case IDENTIFIER:
     case STRING_LITERAL:
     case INTEGER_LITERAL:
     case DOUBLE_LITERAL:
     case PARENTHESIS_OPEN:
     case PLUS:
     case HYPHEN:
       state.popParserState();
       state.pushParserState(VARIABLE_CLOSE);
       startExpressionMode(token, state);
       return;
     default:
       startSyntaxErrorMode(token, state);
   }
 }
예제 #5
0
파일: ParserState.java 프로젝트: kr9ly/teit
 @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));
   }
 }
예제 #6
0
파일: ParserState.java 프로젝트: kr9ly/teit
 @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);
   }
 }
예제 #7
0
파일: ParserState.java 프로젝트: kr9ly/teit
    @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);
      }
    }
예제 #8
0
파일: ParserState.java 프로젝트: kr9ly/teit
 protected void startExpressionMode(Token token, BuilderState state) {
   state.setPendingToken(token);
   state.pushNode(new ExpressionModel());
   state.pushParserState(EXPRESSION_OPEN);
 }
예제 #9
0
파일: ParserState.java 프로젝트: kr9ly/teit
 protected void startSyntaxErrorMode(Token token, BuilderState state) {
   state.setPendingToken(token);
   state.popParserState();
   state.pushParserState(SYNTAX_ERROR_IN_TAG);
 }
예제 #10
0
파일: ParserState.java 프로젝트: kr9ly/teit
 protected void breakTag(Token token, BuilderState state) {
   state.setPendingToken(token);
   state.popParserState();
 }
예제 #11
0
파일: ParserState.java 프로젝트: kr9ly/teit
 @Override
 public void process(Token token, BuilderState state, TemplateEnvironment environment) {
   state.setPendingToken(token);
   state.popNode();
   state.popParserState();
 }
예제 #12
0
파일: ParserState.java 프로젝트: kr9ly/teit
 @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);
   }
 }
예제 #13
0
파일: ParserState.java 프로젝트: kr9ly/teit
 @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));
   }
 }