// cpre_error: error-reporting methods for the preprocessor
#include "CPreParserImp.h"
#include "tokenList.h"
//////////////////////////////////////////////////////////////////
void
CPreParserImp::HandlePndError()
{
fprintf(stdout, "#error: ");
for (
TokenList::iterator iter(tempTokenList->begin());
iter != tempTokenList->end();
iter++
)
{
fprintf(stdout, "%s ", (*iter)->getText());
}
fprintf(stdout, "\n");
}
//////////////////////////////////////////////////////////////////
// HandleError: the format argument may contain an optional %s
// for formatting the token string.
void CPreParserImp::HandleError(
const JLStr& format,
const ANTLRTokenPtr& token
)
{
char buf[512];
sprintf(buf, format.c_str(), token->getText());
fprintf(
stdout,
"Error: line %d: %s\n",
token->getLine(),
buf
);
}
//////////////////////////////////////////////////////////////////
void CPreParserImp::FatalError(
const JLStr& msg
)
{
fprintf(stderr, "%s\n", msg);
exit(1);
}