Examples of ParserDirectiveToken


Examples of cambridge.parser.tokens.ParserDirectiveToken

      firstTag = false;
      return node;
   }

   private TemplateNode parserDirective() throws TemplateParsingException {
      ParserDirectiveToken tok = (ParserDirectiveToken) currentToken;
      if ("include".equalsIgnoreCase(tok.getDirective()) && templateLoader != null) {
         return parseIncludeNode(tok);
      }
      if ("set".equalsIgnoreCase(tok.getDirective())) {
         return parseSetDirective(tok);
      }
      if ("namespace".equalsIgnoreCase(tok.getDirective())) {
         return parseNamespaceDirective(tok);
      }
      if ("expressionLanguage".equalsIgnoreCase(tok.getDirective())) {
         return parseExpressionLanguageDirective(tok);
      }
      if ("debug".equalsIgnoreCase(tok.getDirective())) {
         return new DebugDirective();
      }
      if ("extend".equalsIgnoreCase(tok.getDirective()) || "extends".equalsIgnoreCase(tok.getDirective())) {
         if (template.hasChildren()) {
            throw new TemplateParsingException("extend directive should be the first element of the template", tok.getLineNo(), tok.getColumn());
         }

         return parseExtendsDirective(tok);
      }
View Full Code Here

Examples of cambridge.parser.tokens.ParserDirectiveToken

               }
               nextChar(3);

               builder.append("-->");

               ParserDirectiveToken tok = new ParserDirectiveToken(line, col, builder.toString(), getLineNo(), getColumn(), directive, args);
               if (peek(1) == '\r') {
                  if (peek(2) == '\n') {
                     nextChar(2);
                     tok.setTrailingSpace("\r\n");
                  } else {
                     tok.setTrailingSpace("\r");
                     nextChar();
                  }
               } else if (peek(1) == '\n') {
                  tok.setTrailingSpace("\n");
                  nextChar();
               }
               return tok;
            } else if (peek(1) == '-' && peek(2) == '-') {
               nextChar(2);
               // Comment block
               builder.append("!--");

               while (true) {
                  if (peek(1) == Tokenizer.EOL) {
                     return new CommentToken(line, col, builder.toString(), getLineNo(), getColumn());
                  }
                  if (peek(1) == '-' && peek(2) == '-' && peek(3) == '>') break;
                  builder.append(nextChar());
               }
               nextChar(3);
               builder.append("-->");
               return new CommentToken(line, col, builder.toString(), getLineNo(), getColumn());


               // CDATA Blocks
            } else if ("[CDATA[".equals(peekString(7))) {
               c = nextChar(7);
               builder.append("![CDATA");
               while (true) {
                  builder.append(c);
                  if (peek(1) == Tokenizer.EOL) {
                     return new CDATAToken(line, col, builder.toString(), getLineNo(), getColumn());
                  } else {
                     if (peek(1) == ']' && peek(2) == ']' && peek(3) == '>') {
                        builder.append("]]>");
                        break;
                     }
                  }
                  c = nextChar();
               }
               nextChar(3);
               return new CDATAToken(line, col, builder.toString(), getLineNo(), getColumn());

               // DOCTYPE DECLARATIONS
            } else {
               while (c != '>') {
                  builder.append(c);
                  if (peek(1) == Tokenizer.EOL) {
                     break;
                  }
                  c = nextChar();
               }

               if (c == '>') {
                  builder.append(c);
               }
               return new DocTypeToken(line, col, builder.toString(), getLineNo(), getColumn());
            }
            // TAG CLOSE </X>
         } else if (peek(1) == '/') {
            builder.append(c);
            c = nextChar();
            String tagName = null;
            while (c != '>') {
               builder.append(c);
               if (peek(1) == Tokenizer.EOL) {
                  break;
               }
               c = nextChar();

               if (tagName == null && (Character.isWhitespace(c) || c == '>')) {
                  tagName = builder.substring(2).toLowerCase();
               }
            }

            if (c == '>') {
               builder.append(c);
            }

            state = State.INITIAL_STATE;
            CloseTagToken tok = new CloseTagToken(line, col, builder.toString(), getLineNo(), getColumn());

            tok.setTagName(tagName);

            return tok;
            // OPEN TAG <X
         } else if (CharUtil.isLetter((int) peek(1))) {
            c = nextChar();
View Full Code Here

Examples of cambridge.parser.tokens.ParserDirectiveToken

        firstTag = false;
        return node;
    }

    private TemplateNode parserDirective() throws TemplateParsingException {
        ParserDirectiveToken tok = (ParserDirectiveToken) currentToken;
        if ("include".equalsIgnoreCase(tok.getDirective()) && templateLoader != null) {
            return parseIncludeNode(tok);
        }
        if ("set".equalsIgnoreCase(tok.getDirective())) {
            return parseSetDirective(tok);
        }
        if ("namespace".equalsIgnoreCase(tok.getDirective())) {
            return parseNamespaceDirective(tok);
        }
        if ("expressionLanguage".equalsIgnoreCase(tok.getDirective())) {
            return parseExpressionLanguageDirective(tok);
        }
        if ("debug".equalsIgnoreCase(tok.getDirective())) {
            return new DebugDirective();
        }
        if ("extend".equalsIgnoreCase(tok.getDirective()) || "extends".equalsIgnoreCase(tok.getDirective())) {
            if (template.hasChildren()) {
                throw new TemplateParsingException("extend directive should be the first element of the template", tok.getLineNo(), tok.getColumn());
            }

            return parseExtendsDirective(tok);
        }
View Full Code Here

Examples of cambridge.parser.tokens.ParserDirectiveToken

               }
               nextChar(3);

               builder.append("-->");

               ParserDirectiveToken tok = new ParserDirectiveToken(line, col, builder.toString(), getLineNo(), getColumn(), directive, args);
               if (peek(1) == '\r') {
                  if (peek(2) == '\n') {
                     nextChar(2);
                     tok.setTrailingSpace("\r\n");
                  } else {
                     tok.setTrailingSpace("\r");
                     nextChar();
                  }
               } else if (peek(1) == '\n') {
                  tok.setTrailingSpace("\n");
                  nextChar();
               }
               return tok;
            } else if (peek(1) == '-' && peek(2) == '-') {
               nextChar(2);
               // Comment block
               builder.append("!--");

               while (true) {
                  if (peek(1) == Tokenizer.EOL) {
                     return new CommentToken(line, col, builder.toString(), getLineNo(), getColumn());
                  }
                  if (peek(1) == '-' && peek(2) == '-' && peek(3) == '>') break;
                  builder.append(nextChar());
               }
               nextChar(3);
               builder.append("-->");
               return new CommentToken(line, col, builder.toString(), getLineNo(), getColumn());


               // CDATA Blocks
            } else if ("[CDATA[".equals(peekString(7))) {
               c = nextChar(7);
               builder.append("![CDATA");
               while (true) {
                  builder.append(c);
                  if (peek(1) == Tokenizer.EOL) {
                     return new CDATAToken(line, col, builder.toString(), getLineNo(), getColumn());
                  } else {
                     if (peek(1) == ']' && peek(2) == ']' && peek(3) == '>') {
                        builder.append("]]>");
                        break;
                     }
                  }
                  c = nextChar();
               }
               nextChar(3);
               return new CDATAToken(line, col, builder.toString(), getLineNo(), getColumn());

               // DOCTYPE DECLARATIONS
            } else {
               while (c != '>') {
                  builder.append(c);
                  if (peek(1) == Tokenizer.EOL) {
                     break;
                  }
                  c = nextChar();
               }

               if (c == '>') {
                  builder.append(c);
               }
               return new DocTypeToken(line, col, builder.toString(), getLineNo(), getColumn());
            }
            // TAG CLOSE </X>
         } else if (peek(1) == '/') {
            builder.append(c);
            c = nextChar();
            String tagName = null;
            while (c != '>') {
               builder.append(c);
               if (peek(1) == Tokenizer.EOL) {
                  break;
               }
               c = nextChar();

               if (tagName == null && (Character.isWhitespace(c) || c == '>')) {
                  tagName = builder.substring(2).toLowerCase();
               }
            }

            if (c == '>') {
               builder.append(c);
            }

            state = State.INITIAL_STATE;
            CloseTagToken tok = new CloseTagToken(line, col, builder.toString(), getLineNo(), getColumn());

            tok.setTagName(tagName);

            return tok;
            // OPEN TAG <X
         } else if (CharUtil.isLetter((int) peek(1))) {
            c = nextChar();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.