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

use a stringstream in parse any, gather all exceptions so more useful info is...

use a stringstream in parse any, gather all exceptions so more useful info is displayed in case all rules fail

Conflicts:

	libwccl/parser/Parser.cpp
parent 5b46a726
No related branches found
No related tags found
No related merge requests found
......@@ -134,39 +134,45 @@ boost::shared_ptr<ANTLRParserResultBase> Parser::parseAnyOperator(
boost::shared_ptr<ANTLRParserResultBase> Parser::parseAnyOperator(
std::istream& istr) const
{
std::stringstream ss;
ss << istr.rdbuf();
std::stringstream errors;
boost::shared_ptr<ANTLRParserResultBase> result;
if (!result) {
istr.seekg(0);
ANTLRLexer lexer(istr);
ss.seekg(0, std::ios::beg);
ANTLRLexer lexer(ss);
ANTLRParser parser(lexer);
try {
result = parser.parse_sym_set_operator(tagset_);
} catch (antlr::ANTLRException) {
} catch (antlr::ANTLRException& e) {
errors << "(as tset) " << e.getMessage() << "\n";
// ignore, try another type
}
}
if (!result) {
istr.clear();
istr.seekg(0);
ANTLRLexer lexer(istr);
ss.seekg(0, std::ios::beg);
ANTLRLexer lexer(ss);
ANTLRParser parser(lexer);
try {
result = parser.parse_string_operator(tagset_);
} catch (antlr::ANTLRException) {
} catch (antlr::ANTLRException& e) {
errors << "(as strset) " << e.getMessage() << "\n";
// ignore, try another type
}
}
if (!result) {
istr.clear();
istr.seekg(0);
ANTLRLexer lexer(istr);
ss.seekg(0, std::ios::beg);
ANTLRLexer lexer(ss);
ANTLRParser parser(lexer);
try {
result = parser.parse_predicates(tagset_);
} catch (antlr::ANTLRException) {
throw;
} catch (antlr::ANTLRException& e) {
errors << "(as predicate) " << e.getMessage() << "\n";
// ignore, try another type
}
}
if (!result) {
throw ParserException(errors.str());
}
assert(result);
return result;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment