Package com.google.caja.lexer.TokenQueue

Examples of com.google.caja.lexer.TokenQueue.Mark


  private FormalParamList parseFormalParams() throws ParseException {
    List<FormalParam> params = Lists.newArrayList();
    if (!tq.lookaheadToken(Punctuation.RPAREN)) {
      do {
        Mark m = tq.mark();
        FormalParam param = new FormalParam(parseIdentifierNode(false));
        finish(param, m);
        params.add(param);
      } while (tq.checkToken(Punctuation.COMMA));
    }
View Full Code Here


   * Attaches to the parse tree filtered tokens,
   * such as type annotation carrying comments.
   */
  private void finish(AbstractParseTreeNode n, Mark startMark)
      throws ParseException {
    Mark endMark = tq.mark();
    tq.rewind(startMark);
    try {
      n.setComments(tq.filteredTokens());
    } finally {
      tq.rewind(endMark);
View Full Code Here

    // stylesheet
    //   : [ CHARSET_SYM STRING ';' ]?
    //     [S|CDO|CDC]* [ import [S|CDO|CDC]* ]*
    //     [ [ ruleset | media | page ] [S|CDO|CDC]* ]*
    try {
      Mark m = tq.mark();
      List<CssTree.CssStatement> stmts = Lists.newArrayList();

      if (lookaheadSymbol("@charset ", false)) {
        addIfNotNull(stmts, parseCharset());
      }
View Full Code Here

  /** Parse a series of CSS properties as seen in an XHTML style attribute. */
  public CssTree.DeclarationGroup parseDeclarationGroup()
      throws ParseException {
    try {
      Mark m = tq.mark();
      List<CssTree.Declaration> decls = Lists.newArrayList();
      while (!tq.isEmpty()) {
        while (tq.lookaheadToken(";")) { tq.advance(); }
        if (tq.isEmpty()) { break; }
        addIfNotNull(decls, parseDeclaration());
View Full Code Here

  }

  // All the non-public parse methods below may return null in tolerant mode.

  private CssTree.Charset parseCharset() throws ParseException {
    Mark m = tq.mark();
    expectSymbol("@charset ", false);

    Token<CssTokenType> t = tq.pop();
    String charset = null;
    if (CssTokenType.STRING == t.type) {
View Full Code Here

    }
    return new CssTree.Charset(pos(m), charset);
  }

  private CssTree.Import parseImport() throws ParseException {
    Mark m = tq.mark();
    expectSymbol("@import");
    CssTree.UriLiteral uri = parseUri();
    if (uri == null) {
      SKIP_TO_CHUNK_END_FROM_OUTSIDE_BLOCK.recover(this, m);
      return null;
View Full Code Here

    }
    return new CssTree.Import(pos(m), uri, media);
  }

  private CssTree.Medium parseMedium() throws ParseException {
    Mark m = tq.mark();
    String ident = expectIdent();
    if (ident == null) { return null; }
    return new CssTree.Medium(pos(m), Name.css(ident));
  }
View Full Code Here

      } else if (lookaheadSymbol("@page")) {
        return parsePage();
      } else if (lookaheadSymbol("@font-face")) {
        return parseFontFace();
      } else if (isTolerant) {
        Mark m = tq.mark();
        tq.advance();
        SKIP_TO_CHUNK_END_FROM_OUTSIDE_BLOCK.recover(this, m);
        return null;
      }
    } else if (isTolerant && ";".equals(t.text)) {
View Full Code Here

    }
    return parseRuleSet();
  }

  private CssTree.Media parseMedia() throws ParseException {
    Mark m = tq.mark();
    expectSymbol("@media");
    List<CssTree> children = Lists.newArrayList();
    do {
      CssTree.Medium medium = parseMedium();
      if (medium == null) {
View Full Code Here

    }
    return new CssTree.Media(pos(m), children);
  }

  private CssTree.Page parsePage() throws ParseException {
    Mark m = tq.mark();
    expectSymbol("@page");
    Token<CssTokenType> t = tq.peek();
    String ident = null;
    if (CssTokenType.IDENT == t.type) {
      ident = unescape(t);
      tq.advance();
    }
    List<CssTree.PageElement> elements = Lists.newArrayList();
    if (tq.lookaheadToken(":")) {
      Mark m2 = tq.mark();
      tq.expectToken(":");
      String pseudoPage = expectIdent();
      if (pseudoPage == null) {
        SKIP_TO_CHUNK_END_FROM_OUTSIDE_BLOCK.recover(this, m);
        return null;
View Full Code Here

TOP

Related Classes of com.google.caja.lexer.TokenQueue.Mark

Copyright © 2018 www.massapicom. 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.