Exemple #1
0
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();
	}
}
Exemple #2
0
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();
	}
}
Exemple #3
0
/**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();
    }
}
Exemple #4
0
/**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();
    }
}
Exemple #5
0
/**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();
	}
}
Exemple #6
0
/**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();
	}
}
Exemple #7
0
 void match(int type_name) {
     if (lookaheadType(1) == type_name)
         consume();
     else
         throw MismatchedTokenException(type_name, lookaheadType(1));
 }
Exemple #8
0
void TreeParser::matchNot(RefAST t, int ttype)
{
	if ( !t || t == ASTNULL || t->getType() == ttype )
		throw MismatchedTokenException( getTokenNames(), getNumTokens(),
												  t, ttype, true );
}
Exemple #9
0
/** 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 );
}
Exemple #10
0
	virtual void match(RefAST t, int ttype)
	{
		if (!t || t == ASTNULL || t->getType() != ttype )
			throw MismatchedTokenException( getTokenNames(), getNumTokens(),
													  t, ttype, false );
	}
Exemple #11
0
/**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();
	}
}
Exemple #12
0
void TreeParser::match(RefAST t, int ttype)
{
	if (!t || t==ASTNULL || t->getType()!=ttype)
		throw MismatchedTokenException();
}