|
// CPPParserError.cpp: Error handling for the grammar class
#include "CPPParser.h"
#include <iostream>
// virtual
void
CPPParser::ReportError(
const JLStr& errMsg,
const ANTLRTokenPtr& token
)
{
cout << "CPPParser Error: ";
if (token->getLine() == 0)
{
cout << "end of file";
} else {
cout << "line " << token->getLine();
}
cout << " near '" << token->getText() << "': ";
cout << errMsg << endl;
}
//virtual
void
CPPParser::panic(
char *err
)
{
cout << "CPPParser PANIC: " << err << endl;
exit(-1);
}
void
CPPParser::ReportExceptionError(
AParserEX& ex
)
{
JLStr msg;
if (ex.GetEXType() == AParserEX::Syntax)
{
AParserEXSyntax& eSyn = STATIC_CAST(AParserEXSyntax&, ex);
if (set_el(TOK_SEMICOLON, eSyn.set))
{
msg = "missing ';'";
} else if (set_el(TOK_RCURLY, eSyn.set))
{
msg = "missing '}'";
} else {
msg = "syntax error";
}
} else if (ex.GetEXType() == AParserEX::Predicate)
{
AParserEXPredicate& ePred = STATIC_CAST(AParserEXPredicate&, ex);
msg = "predicate '";
msg += ePred.msg;
msg += "' failed";
} else {
msg = "Unknown parser exception!!";
}
ReportError(msg, LT(1));
cout.flush();
}
void
CPPParser::trace_output(
const char* msg
)
{
cout << msg;
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.