Package com.google.caja.lexer.TokenQueue

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


    return ident;
  }

  private ExpressionStmt parseExpressionStmt(boolean insertionProtected)
      throws ParseException {
    Mark m = tq.mark();
    Expression e = parseExpressionInt(insertionProtected);
    ExpressionStmt es = new ExpressionStmt(posFrom(m), e);
    finish(es, m);
    return es;
  }
View Full Code Here


  }

  private Expression parseExpressionOrNoop(
      AbstractExpression def, boolean insertionProtected)
      throws ParseException {
    Mark m = tq.mark();
    if (tq.checkToken(Punctuation.SEMI)) {
      finish(def, m);
      return def;
    }
    Expression e = parseExpressionInt(insertionProtected);
View Full Code Here

  }

  private AbstractStatement parseDeclarationsOrExpression(
      boolean insertionProtected)
      throws ParseException {
    Mark m = tq.mark();

    boolean isDeclaration;

    if (tq.checkToken(Keyword.VAR)) {
      isDeclaration = true;
    } else if (tq.checkToken(Keyword.CONST)) {
      isDeclaration = true;
      mq.addMessage(MessageType.NOT_IE, posFrom(m));
    } else {
      isDeclaration = false;
    }

    if (isDeclaration) {
      AbstractStatement s;
      Declaration d;
      {
        Identifier idNode = parseIdentifierNode(false);
        Expression initializer = null;
        if (tq.checkToken(Punctuation.EQ)) {
          initializer = parseExpressionPart(insertionProtected);
        }
        d = new Declaration(posFrom(m), idNode, initializer);
        finish(d, m);
      }
      if (tq.checkToken(Punctuation.COMMA)) {
        List<Declaration> decls = Lists.newArrayList();
        decls.add(d);
        do {
          Mark m2 = tq.mark();
          Identifier idNode = parseIdentifierNode(false);
          Expression initializer = null;
          if (tq.checkToken(Punctuation.EQ)) {
            initializer = parseExpressionPart(insertionProtected);
          }
View Full Code Here

  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

  private Function<DOMImplementation, DocumentType> findDoctype()
      throws ParseException {
    if (tokens.isEmpty()) { return null; }
    Function<DOMImplementation, DocumentType> doctypeMaker = null;
    Mark start = tokens.mark();

    doctypeloop:
    while (!tokens.isEmpty()) {
      Token<HtmlTokenType> t = tokens.peek();
      switch (t.type) {
View Full Code Here

  private Function<DOMImplementation, DocumentType> findDoctype()
      throws ParseException {
    if (tokens.isEmpty()) { return null; }
    Function<DOMImplementation, DocumentType> doctypeMaker = null;
    Mark start = tokens.mark();

    doctypeloop:
    while (!tokens.isEmpty()) {
      Token<HtmlTokenType> t = tokens.peek();
      switch (t.type) {
View Full Code Here

  }

  /** Parses and returns a Statement. */
  public Statement parseStatement() throws ParseException {
    // look for any labels preceding statement
    Mark m = tq.mark();
    Token<JsTokenType> t = tq.peek();
    if (JsTokenType.WORD == t.type) {
      String label = parseIdentifier(false);
      FilePosition labelPos = t.pos;
      if (tq.checkToken(Punctuation.COLON)) {
View Full Code Here

    return parseProgramOrFunctionBody(false);
  }

  private Block parseProgramOrFunctionBody(boolean requireBrackets)
      throws ParseException {
    Mark m = tq.mark();
    if (requireBrackets) { tq.expectToken(Punctuation.LCURLY); }
    List<Statement> stmts = Lists.newArrayList();
    DirectivePrologue prologue = parseOptionalDirectivePrologue();
    if (prologue != null) { stmts.add(prologue); }
    while (!tq.isEmpty() && !tq.lookaheadToken(Punctuation.RCURLY)) {
View Full Code Here

  private DirectivePrologue parseOptionalDirectivePrologue()
      throws ParseException {
    // Quick return if we are sure we will not accumulate anything
    if (tq.isEmpty() || tq.peek().type != JsTokenType.STRING) { return null; }

    Mark startOfPrologue = tq.mark();
    List<Directive> directives = Lists.newArrayList();

    while (!tq.isEmpty() && tq.peek().type == JsTokenType.STRING) {
      Mark startOfDirective = tq.mark();
      Token<JsTokenType> quotedString = tq.pop();

      if (!tq.checkToken(Punctuation.SEMI)) {
        Token<JsTokenType> t = !tq.isEmpty() ? tq.peek() : null;
        if ((t == null || !continuesExpr(t.text)) && semicolonInserted()) {
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.