Esempio n. 1
0
// Verify that the next token in the input file is of the same type
// that the parser expects.
TokenClass ParserClass::Match(TokenType expectedType)
{
	TokenClass currentToken = this->mScanner->GetNextToken();
	if (currentToken.GetTokenType() != expectedType)
	{
		std::cerr << "Error in ParserClass::Match. " << std::endl;
		std::cerr << "Expected token type " <<
			TokenClass::GetTokenTypeName(expectedType) <<
			", but got type " << currentToken.GetTokenTypeName() <<
			std::endl;
		exit(1);
	}
	MSG("\tSuccessfully matched Token Type: " << currentToken.GetTokenTypeName() << ". Lexeme: \"" <<
		currentToken.GetLexeme() << "\"");
	return currentToken; // the one we just processed
}
Esempio n. 2
0
TokenClass ParserClass::Match(TokenType expectedType) {
    TokenClass currToken = mScanner->GetNextToken();
    if (currToken.GetTokenType() != expectedType) {
        cerr << "Error in ParserClass::Match. " << endl;
        cerr << "Recieved token type " << currToken.GetTokenTypeName() << endl;
        exit(1);
    }
    MSG("Sucessfully matched Token Type: " <<
        currentToken.GetTokenTypeName() << ". Lexeme: \"" <<
        currentToken.GetLexeme() << "\"");
    
    return currToken;
}