1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
|
#include "parser.ih"
namespace
{
bool repeated;
string eoln("<EOLN>");
}
void Parser::error()
{
if (!d_doError) // this allows functions to call ERROR and handle
{ // their own error message
d_doError = true;
return;
}
if (d_expect.empty())
{
if (not repeated)
emsg << "unrecognized input (`" << d_matched <<
"') encountered" << endl;
repeated = true;
}
else
{
string const *txt = &d_matched;
if (*txt == "\n")
txt = &::eoln;
if (s_lastMsg != d_expect)
{
if (txt == &::eoln)
emsg.setLineNr(d_scanner.lineNr());
emsg << "at `" << *txt << "': " << d_expect << " expected." << endl;
repeated = false;
}
}
s_lastMsg = d_expect;
}
|