Package com.google.dart.engine.scanner

Examples of com.google.dart.engine.scanner.Token


      reportErrorForCurrentToken(ParserErrorCode.ABSTRACT_TOP_LEVEL_VARIABLE);
    }
    if (modifiers.getExternalKeyword() != null) {
      reportErrorForToken(ParserErrorCode.EXTERNAL_FIELD, modifiers.getExternalKeyword());
    }
    Token constKeyword = modifiers.getConstKeyword();
    Token finalKeyword = modifiers.getFinalKeyword();
    Token varKeyword = modifiers.getVarKeyword();
    if (constKeyword != null) {
      if (finalKeyword != null) {
        reportErrorForToken(ParserErrorCode.CONST_AND_FINAL, finalKeyword);
      }
      if (varKeyword != null) {
View Full Code Here


   * Return {@code true} if the current token appears to be the beginning of a switch member.
   *
   * @return {@code true} if the current token appears to be the beginning of a switch member
   */
  private boolean isSwitchMember() {
    Token token = currentToken;
    while (tokenMatches(token, TokenType.IDENTIFIER)
        && tokenMatches(token.getNext(), TokenType.COLON)) {
      token = token.getNext().getNext();
    }
    if (token.getType() == TokenType.KEYWORD) {
      Keyword keyword = ((KeywordToken) token).getKeyword();
      return keyword == Keyword.CASE || keyword == Keyword.DEFAULT;
    }
    return false;
  }
View Full Code Here

   *
   * @param startToken the first token of the sequence being checked
   * @return {@code true} if there is a type name and variable starting at the given token
   */
  private boolean isTypedIdentifier(Token startToken) {
    Token token = skipReturnType(startToken);
    if (token == null) {
      return false;
    } else if (tokenMatchesIdentifier(token)) {
      return true;
    } else if (tokenMatchesKeyword(token, Keyword.THIS)
        && tokenMatches(token.getNext(), TokenType.PERIOD)
        && tokenMatchesIdentifier(token.getNext().getNext())) {
      return true;
    }
    return false;
  }
View Full Code Here

   *
   * @param tokens the tokens being compared
   * @return the token with the smallest offset
   */
  private Token lexicallyFirst(Token... tokens) {
    Token first = null;
    int firstOffset = Integer.MAX_VALUE;
    for (Token token : tokens) {
      if (token != null) {
        int offset = token.getOffset();
        if (offset < firstOffset) {
View Full Code Here

    TokenType currentType = currentToken.getType();
    if (currentType == TokenType.GT) {
      return true;
    } else if (currentType == TokenType.GT_GT) {
      int offset = currentToken.getOffset();
      Token first = new Token(TokenType.GT, offset);
      Token second = new Token(TokenType.GT, offset + 1);
      second.setNext(currentToken.getNext());
      first.setNext(second);
      currentToken.getPrevious().setNext(first);
      currentToken = first;
      return true;
    } else if (currentType == TokenType.GT_EQ) {
      int offset = currentToken.getOffset();
      Token first = new Token(TokenType.GT, offset);
      Token second = new Token(TokenType.EQ, offset + 1);
      second.setNext(currentToken.getNext());
      first.setNext(second);
      currentToken.getPrevious().setNext(first);
      currentToken = first;
      return true;
    } else if (currentType == TokenType.GT_GT_EQ) {
      int offset = currentToken.getOffset();
      Token first = new Token(TokenType.GT, offset);
      Token second = new Token(TokenType.GT, offset + 1);
      Token third = new Token(TokenType.EQ, offset + 2);
      third.setNext(currentToken.getNext());
      second.setNext(third);
      first.setNext(second);
      currentToken.getPrevious().setNext(first);
      currentToken = first;
      return true;
View Full Code Here

      expression = new SuperExpression(getAndAdvance());
    } else {
      expression = parseMultiplicativeExpression();
    }
    while (currentToken.getType().isAdditiveOperator()) {
      Token operator = getAndAdvance();
      expression = new BinaryExpression(expression, operator, parseMultiplicativeExpression());
    }
    return expression;
  }
View Full Code Here

   * </pre>
   *
   * @return the assert statement
   */
  private AssertStatement parseAssertStatement() {
    Token keyword = expectKeyword(Keyword.ASSERT);
    Token leftParen = expect(TokenType.OPEN_PAREN);
    Expression expression = parseExpression();
    if (expression instanceof AssignmentExpression) {
      reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_ASSIGNMENT, expression);
    } else if (expression instanceof CascadeExpression) {
      reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_CASCADE, expression);
    } else if (expression instanceof ThrowExpression) {
      reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_THROW, expression);
    } else if (expression instanceof RethrowExpression) {
      reportErrorForNode(ParserErrorCode.ASSERT_DOES_NOT_TAKE_RETHROW, expression);
    }
    Token rightParen = expect(TokenType.CLOSE_PAREN);
    Token semicolon = expect(TokenType.SEMICOLON);
    return new AssertStatement(keyword, leftParen, expression, rightParen, semicolon);
  }
View Full Code Here

   * @return the assignable selector that was parsed, or the original prefix if there was no
   *         assignable selector
   */
  private Expression parseAssignableSelector(Expression prefix, boolean optional) {
    if (matches(TokenType.OPEN_SQUARE_BRACKET)) {
      Token leftBracket = getAndAdvance();
      boolean wasInInitializer = inInitializer;
      inInitializer = false;
      try {
        Expression index = parseExpression();
        Token rightBracket = expect(TokenType.CLOSE_SQUARE_BRACKET);
        return new IndexExpression(prefix, leftBracket, index, rightBracket);
      } finally {
        inInitializer = wasInInitializer;
      }
    } else if (matches(TokenType.PERIOD)) {
      Token period = getAndAdvance();
      return new PropertyAccess(prefix, period, parseSimpleIdentifier());
    } else {
      if (!optional) {
        // Report the missing selector.
        reportErrorForCurrentToken(ParserErrorCode.MISSING_ASSIGNABLE_SELECTOR);
View Full Code Here

   * </pre>
   *
   * @return the await expression that was parsed
   */
  private AwaitExpression parseAwaitExpression() {
    Token awaitToken = getAndAdvance();
    Expression expression = parseUnaryExpression();
    return new AwaitExpression(awaitToken, expression);
  }
View Full Code Here

      expression = new SuperExpression(getAndAdvance());
    } else {
      expression = parseShiftExpression();
    }
    while (matches(TokenType.AMPERSAND)) {
      Token operator = getAndAdvance();
      expression = new BinaryExpression(expression, operator, parseShiftExpression());
    }
    return expression;
  }
View Full Code Here

TOP

Related Classes of com.google.dart.engine.scanner.Token

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.