void TreeParser::matchNot(RefAST t, int ttype) { //ANTLR_USE_NAMESPACE(std)cout << "match(" << ttype << "); cursor is " << t.toString() << ANTLR_USE_NAMESPACE(std)endl; if ( !t || t==ASTNULL || t->getType()==ttype ) { throw MismatchedTokenException(); } }
void Parser::matchNot(int t) { if ( LA(1)==t ) { // Throws inverted-sense exception throw MismatchedTokenException(getTokenNames(), getNumTokens(), LT(1), t, true, getFilename()); } else { // mark token as consumed -- fetch next token deferred until LA/LT consume(); } }
/**Make sure current lookahead symbol matches token type <tt>t</tt>. * Throw an exception upon mismatch, which is catch by either the * error handler or by the syntactic predicate. */ void Parser::match(int t) { if ( DEBUG_PARSER ) std::cout << "enter match(" << t << ") with LA(1)=" << LA(1) << std::endl; if ( LA(1)!=t ) { if ( DEBUG_PARSER ) std::cout << "token mismatch: " << LA(1) << "!=" << t << std::endl; throw MismatchedTokenException(tokenNames, LT(1), t, 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 ) 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 token type <tt>t</tt>. * Throw an exception upon mismatch, which is catch by either the * error handler or by the syntactic predicate. */ void Parser::match(int t) { if ( DEBUG_PARSER ) { traceIndent(); ANTLR_USE_NAMESPACE(std)cout << "enter match(" << t << ") with LA(1)=" << LA(1) << ANTLR_USE_NAMESPACE(std)endl; } if ( LA(1)!=t ) { if ( DEBUG_PARSER ) { traceIndent(); ANTLR_USE_NAMESPACE(std)cout << "token mismatch: " << LA(1) << "!=" << t << ANTLR_USE_NAMESPACE(std)endl; } throw MismatchedTokenException(getTokenNames(), getNumTokens(), LT(1), t, false, getFilename()); } 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(); } }
void match(int type_name) { if (lookaheadType(1) == type_name) consume(); else throw MismatchedTokenException(type_name, lookaheadType(1)); }
void TreeParser::matchNot(RefAST t, int ttype) { if ( !t || t == ASTNULL || t->getType() == ttype ) throw MismatchedTokenException( getTokenNames(), getNumTokens(), t, ttype, true ); }
/** 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 ); }
virtual void match(RefAST t, int ttype) { if (!t || t == ASTNULL || t->getType() != ttype ) throw MismatchedTokenException( getTokenNames(), getNumTokens(), t, ttype, 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(); } }
void TreeParser::match(RefAST t, int ttype) { if (!t || t==ASTNULL || t->getType()!=ttype) throw MismatchedTokenException(); }