Exemple #1
0
 @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);
   }
 }
Exemple #2
0
 @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);
   }
 }
Exemple #3
0
 @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;
     default:
       startSyntaxErrorMode(token, state);
   }
 }
Exemple #4
0
    @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);
      }
    }
Exemple #5
0
 @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);
   }
 }
Exemple #6
0
 @Override
 public void process(Token token, BuilderState state, TemplateEnvironment environment) {
   state.setPendingToken(token);
   state.popNode();
   state.popParserState();
 }