Package com.google.caja.lexer.TokenQueue

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


    return new CssTree.Page(
        pos(m), ident == null ? null : Name.css(ident), elements);
  }

  private CssTree.FontFace parseFontFace() throws ParseException {
    Mark m = tq.mark();
    expectSymbol("@font-face");
    List<CssTree.Declaration> elements = Lists.newArrayList();
    if (parseDeclarationBlock(elements, m)) { return null; }
    return new CssTree.FontFace(pos(m), elements);
  }
View Full Code Here


    } while (tq.checkToken(";"));
    return expect("}", SKIP_TO_CHUNK_END_FROM_WITHIN_BLOCK, start);
  }

  private CssTree.Operation parseOperation() throws ParseException {
    Mark m = tq.mark();
    CssTree.Operator op = CssTree.Operator.NONE;
    if (!tq.isEmpty()) {
      Token<CssTokenType> t = tq.peek();
      if (CssTokenType.PUNCTUATION == t.type) {
        if ("/".equals(t.text)) {
View Full Code Here

    }
    return new CssTree.Operation(pos(m), op);
  }

  private CssTree.Combination parseCombinator() throws ParseException {
    Mark m = tq.mark();
    CssTree.Combinator comb = CssTree.Combinator.DESCENDANT;
    if (!tq.isEmpty()) {
      Token<CssTokenType> t = tq.peek();
      if (CssTokenType.PUNCTUATION == t.type) {
        if ("+".equals(t.text)) {
View Full Code Here

    }
    return new CssTree.Combination(pos(m), comb);
  }

  private CssTree.Property parseProperty() throws ParseException {
    Mark m = tq.mark();
    String ident = expectIdent();
    if (ident == null && isTolerant) { return null; }

    // When !isTolerant, expectIdent throws instead of returning null.
    assert ident != null;
View Full Code Here

    return new CssTree.Property(pos(m), Name.css(ident));
  }


  private CssTree.RuleSet parseRuleSet() throws ParseException {
    Mark m = tq.mark();
    List<CssTree> elements = Lists.newArrayList();
    do {
      CssTree.Selector sel = parseSelector();
      addIfNotNull(elements, sel);
    } while (tq.checkToken(","));
View Full Code Here

    if (parseDeclarationBlock(elements, m)) { return null; }
    return new CssTree.RuleSet(pos(m), elements);
  }

  private CssTree.Selector parseSelector() throws ParseException {
    Mark m = tq.mark();
    List<CssTree> elements = Lists.newArrayList();
    while (true) {
      if (!elements.isEmpty()) {
        elements.add(parseCombinator());
      }
View Full Code Here

    }
    return new CssTree.Selector(pos(m), elements);
  }

  private CssTree.SimpleSelector parseSimpleSelector() throws ParseException {
    Mark m = tq.mark();
    List<CssTree> elements = Lists.newArrayList();
    if (!tq.isEmpty()) {
      Token<CssTokenType> t = tq.peek();
      if (CssTokenType.IDENT == t.type) {
        String elementName = unescape(t);
View Full Code Here

    }
    return new CssTree.SimpleSelector(pos(m), elements);
  }

  private CssTree.ClassLiteral parseClass() throws ParseException {
    Mark m = tq.mark();
    tq.expectToken(".");
    String ident = expectIdent();
    if (ident == null) { return null; }
    return new CssTree.ClassLiteral(pos(m), "." + ident);
  }
View Full Code Here

    if (ident == null) { return null; }
    return new CssTree.ClassLiteral(pos(m), "." + ident);
  }

  private CssTree.Attrib parseAttrib() throws ParseException {
    Mark m = tq.mark();
    tq.expectToken("[");
    String ident = expectIdent();
    if (ident == null) { return null; }
    CssTree.AttribOperation op = null;
    if (isTolerant && tq.isEmpty()) { return null; }
View Full Code Here

    if (expect("]", DO_NOTHING, m)) { return null; }
    return new CssTree.Attrib(pos(m), ident, op, value);
  }

  private CssTree.Pseudo parsePseudo() throws ParseException {
    Mark m = tq.mark();
    tq.expectToken(":");
    Mark m2 = tq.mark();
    if (isTolerant && tq.isEmpty()) { return null; }
    Token<CssTokenType> t = tq.peek();
    CssTree.CssExprAtom atom;
    if (CssTokenType.FUNCTION == t.type) {
      String fnName = unescape(t);
      fnName = fnName.substring(0, fnName.length() - 1); // strip trailing (
      tq.advance();
      Mark m3 = tq.mark();
      String argIdent = expectIdent();
      if (argIdent == null) { return null; }
      FilePosition pos3 = pos(m3);
      CssTree.IdentLiteral lit = new CssTree.IdentLiteral(pos3, argIdent);
      CssTree.Term term = new CssTree.Term(pos3, null, lit);
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.