/**Make sure current lookahead symbol matches the given set * Throw an exception upon mismatch, which is catch by either the * error handler or by the syntactic predicate. */ void Parser::match(const BitSet& b) { if ( DEBUG_PARSER ) std::cout << "enter match(" << "bitset" /*b.toString()*/ << ") with LA(1)=" << LA(1) << std::endl; if ( !b.member(LA(1)) ) { if ( DEBUG_PARSER ) std::cout << "token mismatch: " << LA(1) << " not member of " << "bitset" /*b.toString()*/ << std::endl; throw MismatchedTokenException(tokenNames, LT(1), b, false); } else { // mark token as consumed -- fetch next token deferred until LA/LT consume(); } }
/**Make sure current lookahead symbol matches the given set * Throw an exception upon mismatch, which is catch by either the * error handler or by the syntactic predicate. */ void Parser::match(const BitSet& b) { if ( DEBUG_PARSER ) { traceIndent(); ANTLR_USE_NAMESPACE(std)cout << "enter match(" << "bitset" /*b.toString()*/ << ") with LA(1)=" << LA(1) << ANTLR_USE_NAMESPACE(std)endl; } if ( !b.member(LA(1)) ) { if ( DEBUG_PARSER ) { traceIndent(); ANTLR_USE_NAMESPACE(std)cout << "token mismatch: " << LA(1) << " not member of " << "bitset" /*b.toString()*/ << ANTLR_USE_NAMESPACE(std)endl; } throw MismatchedTokenException(getTokenNames(), getNumTokens(), LT(1), b, false, getFilename()); } else { // mark token as consumed -- fetch next token deferred until LA/LT consume(); } }
/** Consume tokens until one matches the given token set */ void Parser::consumeUntil(const BitSet& set) { while (LA(1) != Token::EOF_TYPE && !set.member(LA(1))) consume(); }
/** Make sure current lookahead symbol matches the given set * Throw an exception upon mismatch, which is caught by either the * error handler or by the syntactic predicate. */ void TreeParser::match(RefAST t, const BitSet& b) { if ( !t || t==ASTNULL || !b.member(t->getType()) ) throw MismatchedTokenException( getTokenNames(), getNumTokens(), t, b, false ); }
/**Make sure current lookahead symbol matches the given set * Throw an exception upon mismatch, which is caught by either the * error handler or by the syntactic predicate. */ void TreeParser::match(RefAST t, const BitSet& b) { if ( !t || t==ASTNULL || !b.member(t->getType()) ) { throw MismatchedTokenException(); } }