Skip to content
Snippets Groups Projects
Commit 9763a632 authored by ilor's avatar ilor
Browse files

better error handling in wcclrun

parent d0641288
No related merge requests found
......@@ -17,7 +17,7 @@
#include <antlr/MismatchedTokenException.hpp>
void load_more_operators(const std::string& filename, Wccl::Parser& parser,
bool load_more_operators(const std::string& filename, Wccl::Parser& parser,
std::vector< boost::shared_ptr<Wccl::FunctionalOperator> >& ops)
{
......@@ -32,6 +32,7 @@ void load_more_operators(const std::string& filename, Wccl::Parser& parser,
retOp = parser.parseAnyOperator(is);
if (retOp) {
ops.push_back(retOp);
return true;
} else {
std::cerr << "Problem while parsing -- "
<< "parser returned NULL!" << std::endl;
......@@ -53,6 +54,7 @@ void load_more_operators(const std::string& filename, Wccl::Parser& parser,
} catch (antlr::ANTLRException& e) {
std::cerr << "Antlr error " << e.getMessage() << std::endl;
}
return false;
}
class streamsave
......@@ -187,7 +189,13 @@ int main(int argc, char** argv)
std::vector< boost::shared_ptr<Wccl::FunctionalOperator> > operators;
Wccl::Parser parser(tagset);
foreach (const std::string& f, ccl_files) {
load_more_operators(f, parser, operators);
int sz = operators.size();
if (!load_more_operators(f, parser, operators)) {
std::cerr << "Warning: error while parsing " << f << "\n";
}
if (operators.size() == sz) {
std::cerr << "Warning: no operators loaded from " << f << "\n";
}
}
if (!operators.empty()) {
foreach (const std::string& f, corpora_files) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment