Fixed error message problem.

This commit is contained in:
yhirose 2015-03-11 17:49:08 -04:00
parent feff9d1d97
commit 7d17f7ce8d

View File

@ -42,12 +42,7 @@ int main(int argc, const char** argv)
peglib::peg peg; peglib::peg peg;
bool firstError = true;
peg.log = [&](size_t ln, size_t col, const string& msg) { peg.log = [&](size_t ln, size_t col, const string& msg) {
if (firstError) {
firstError = false;
cerr << "# PEG grammar syntax error" << endl;
}
cerr << syntax_path << ":" << ln << ":" << col << ": " << msg << endl; cerr << syntax_path << ":" << ln << ":" << col << ": " << msg << endl;
}; };
@ -68,13 +63,8 @@ int main(int argc, const char** argv)
return -1; return -1;
} }
firstError = true;
peg.log = [&](size_t ln, size_t col, const string& msg) { peg.log = [&](size_t ln, size_t col, const string& msg) {
if (firstError) { cerr << source_path << ":" << ln << ":" << col << ": " << msg << endl;
firstError = false;
cerr << "# Source syntax error" << endl;
}
cerr << syntax_path << ":" << ln << ":" << col << ": " << msg << endl;
}; };
if (!peg.parse_n(source.data(), source.size())) { if (!peg.parse_n(source.data(), source.size())) {