Esempio n. 1
0
 /**
  * Assert that the tokens in the actual stream of tokens have the same types and lexemes as the
  * tokens in the expected stream of tokens. Note that this does not assert anything about the
  * offsets of the tokens (although the lengths will be equal).
  *
  * @param expectedStream the head of the stream of tokens that were expected
  * @param actualStream the head of the stream of tokens that were actually found
  * @throws AssertionFailedError if the two streams of tokens are not the same
  */
 public static void assertAllMatch(Token expectedStream, Token actualStream) {
   Token left = expectedStream;
   Token right = actualStream;
   while (left.getType() != TokenType.EOF && right.getType() != TokenType.EOF) {
     assertMatches(left, right);
     left = left.getNext();
     right = right.getNext();
   }
 }
Esempio n. 2
0
 /**
  * Assert that the actual token has the same type and lexeme as the expected token. Note that this
  * does not assert anything about the offsets of the tokens (although the lengths will be equal).
  *
  * @param expectedToken the token that was expected
  * @param actualToken the token that was found
  * @throws AssertionFailedError if the two tokens are not the same
  */
 public static void assertMatches(Token expectedToken, Token actualToken) {
   assertEquals(expectedToken.getType(), actualToken.getType());
   if (expectedToken instanceof KeywordToken) {
     assertInstanceOf(KeywordToken.class, actualToken);
     assertEquals(
         ((KeywordToken) expectedToken).getKeyword(), ((KeywordToken) actualToken).getKeyword());
   } else if (expectedToken instanceof StringToken) {
     assertInstanceOf(StringToken.class, actualToken);
     assertEquals(
         ((StringToken) expectedToken).getLexeme(), ((StringToken) actualToken).getLexeme());
   }
 }
 /**
  * Return {@code true} if this expression is cascaded. If it is, then the target of this
  * expression is not stored locally but is stored in the nearest ancestor that is a {@link
  * CascadeExpression}.
  *
  * @return {@code true} if this expression is cascaded
  */
 public boolean isCascaded() {
   return period != null && period.getType() == TokenType.PERIOD_PERIOD;
 }
 private boolean matches(Token token, Keyword keyword) {
   return token != null
       && token.getType() == TokenType.KEYWORD
       && ((KeywordToken) token).getKeyword() == keyword;
 }