c2c/Parser/Parser.cpp
/// SkipUntil - Read tokens until we get to the specified token, then consume
/// it (unless DontConsume is true).  Because we cannot guarantee that the
/// token will ever occur, this skips to the next token, or to some likely
/// good stopping point.  If StopAtSemi is true, skipping will stop at a ';'
/// character.
///
/// If SkipUntil finds the specified token, it returns true, otherwise it
/// returns false.
Read tokens until we get to the specified token, then consume
it (unless DontConsume is true).  Because we cannot guarantee that the
token will ever occur, this skips to the next token, or to some likely
good stopping point.  If StopAtSemi is true, skipping will stop at a ';'
character.

If SkipUntil finds the specified token, it returns true, otherwise it
returns false.
Read tokens until we get to the specified token then consume it ( unless DontConsume is true ) . Because we cannot guarantee that the token will ever occur this skips to the next token or to some likely good stopping point . If StopAtSemi is true skipping will stop at a ' ; ' character . If SkipUntil finds the specified token it returns true otherwise it returns false .
bool Parser::SkipUntil(ArrayRef<tok::TokenKind> Toks, SkipUntilFlags Flags) {
    bool isFirstTokenSkipped = true;
    while (1) {
        for (unsigned i = 0, NumToks = Toks.size(); i != NumToks; ++i) {
            if (Tok.is(Toks[i])) {
                if (HasFlagsSet(Flags, StopBeforeMatch)) {
                } else {
                    ConsumeAnyToken();
                }
                return true;
            }
        }
        if (Toks.size() == 1 && Toks[0] == tok::eof &&
                !HasFlagsSet(Flags, StopAtSemi)) {
            while (Tok.isNot(tok::eof))
                ConsumeAnyToken();
            return true;
        }
        switch (Tok.getKind()) {
        case tok::eof:
            return false;
        case tok::l_paren:
            ConsumeToken();
            SkipUntil(tok::r_paren);
            break;
        case tok::l_square:
            ConsumeBracket();
            SkipUntil(tok::r_square);
            break;
        case tok::l_brace:
            ConsumeBrace();
            SkipUntil(tok::r_brace);
            break;
        case tok::r_paren:
            if (ParenCount && !isFirstTokenSkipped)
                return false;  
            ConsumeParen();
            break;
        case tok::r_square:
            if (BracketCount && !isFirstTokenSkipped)
                return false;  
            ConsumeBracket();
            break;
        case tok::r_brace:
            if (BraceCount && !isFirstTokenSkipped)
                return false;  
            ConsumeBrace();
            break;
        case tok::string_literal:
        case tok::wide_string_literal:
        case tok::utf8_string_literal:
        case tok::utf16_string_literal:
        case tok::utf32_string_literal:
            ConsumeStringToken();
            break;
        case tok::semi:
            if (HasFlagsSet(Flags, StopAtSemi))
                return false;
        default:
            ConsumeToken();
            break;
        }
        isFirstTokenSkipped = false;
    }
}
bool Parser :: SkipUntil ( ArrayRef < tok :: TokenKind > Toks , SkipUntilFlags Flags ) { bool isFirstTokenSkipped = true ; while ( 1 ) { for ( unsigned i = 0 , NumToks = Toks . size ( ) ; i != NumToks ; ++ i ) { if ( Tok . is ( Toks [ i ] ) ) { if ( HasFlagsSet ( Flags , StopBeforeMatch ) ) { } else { ConsumeAnyToken ( ) ; } return true ; } } if ( Toks . size ( ) == 1 && Toks [ 0 ] == tok :: eof && ! HasFlagsSet ( Flags , StopAtSemi ) ) { while ( Tok . isNot ( tok :: eof ) ) ConsumeAnyToken ( ) ; return true ; } switch ( Tok . getKind ( ) ) { case tok :: eof : return false ; case tok :: l_paren : ConsumeToken ( ) ; SkipUntil ( tok :: r_paren ) ; break ; case tok :: l_square : ConsumeBracket ( ) ; SkipUntil ( tok :: r_square ) ; break ; case tok :: l_brace : ConsumeBrace ( ) ; SkipUntil ( tok :: r_brace ) ; break ; case tok :: r_paren : if ( ParenCount && ! isFirstTokenSkipped ) return false ; ConsumeParen ( ) ; break ; case tok :: r_square : if ( BracketCount && ! isFirstTokenSkipped ) return false ; ConsumeBracket ( ) ; break ; case tok :: r_brace : if ( BraceCount && ! isFirstTokenSkipped ) return false ; ConsumeBrace ( ) ; break ; case tok :: string_literal : case tok :: wide_string_literal : case tok :: utf8_string_literal : case tok :: utf16_string_literal : case tok :: utf32_string_literal : ConsumeStringToken ( ) ; break ; case tok :: semi : if ( HasFlagsSet ( Flags , StopAtSemi ) ) return false ; default : ConsumeToken ( ) ; break ; } isFirstTokenSkipped = false ; } }
SkipUntil - Read tokens until we get to the specified token, then consume
it (unless DontConsume is true).
SkipUntil - Read tokens until we get to the specified token then consume it ( unless DontConsume is true ) .
// We always want this function to skip at least one token if the first token // isn't T and if not at EOF. // If we found one of the tokens, stop and return true. // Noop, don't consume the token. // Important special case: The caller has given up and just wants us to // skip the rest of the file. Do this without recursing, since we can // get here precisely because the caller detected too much recursion. // Ran out of tokens. // Recursively skip properly-nested parens. // Recursively skip properly-nested square brackets. // Recursively skip properly-nested braces. // Okay, we found a ']' or '}' or ')', which we think should be balanced. // Since the user wasn't looking for this token (if they were, it would // already be handled), this isn't balanced.  If there is a LHS token at a // higher level, we will assume that this matches the unbalanced token // and return it.  Otherwise, this is a spurious RHS token, which we skip. // Matches something. // Matches something. // Matches something. // FALL THROUGH. // Skip this token.