Skip to content
Snippets Groups Projects
Commit 1687d4ef authored by Paweł Kędzia's avatar Paweł Kędzia
Browse files

Included line/col/file in Parser exception messages

parent da8c29b9
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,9 @@
#include "ANTLRLexer.hpp"
#include "ANTLRParser.hpp"
#include <antlr/NoViableAltException.hpp>
#include <antlr/MismatchedTokenException.hpp>
namespace Wccl {
/**
......@@ -177,8 +180,19 @@ boost::shared_ptr<ANTLRParserResultBase> Parser::parseAnyOperator(
ANTLRParser parser(lexer);
try {
result = parser.parse_symset_operator(tagset_);
} catch (antlr::MismatchedTokenException &e) {
errors << std::endl
<< "(as tset ) "
<< e.getFileLineColumnString()
<< " " << e.getMessage();
} catch(antlr::NoViableAltException &e) {
errors << std::endl
<< "(as tset ) "
<< e.getFileLineColumnString()
<< " " << e.getMessage();
} catch (antlr::ANTLRException& e) {
errors << "(as tset) " << e.getMessage() << "\n";
errors << std::endl
<< "(as tset ) " << e.getMessage();
// ignore, try another type
}
}
......@@ -189,8 +203,19 @@ boost::shared_ptr<ANTLRParserResultBase> Parser::parseAnyOperator(
ANTLRParser parser(lexer);
try {
result = parser.parse_strset_operator(tagset_);
} catch (antlr::MismatchedTokenException &e) {
errors << std::endl
<< "(as strset ) "
<< e.getFileLineColumnString()
<< " " << e.getMessage();
} catch(antlr::NoViableAltException &e) {
errors << std::endl
<< "(as strset ) "
<< e.getFileLineColumnString()
<< " " << e.getMessage();
} catch (antlr::ANTLRException& e) {
errors << "(as strset) " << e.getMessage() << "\n";
errors << std::endl
<< "(as strset ) " << e.getMessage();
// ignore, try another type
}
}
......@@ -201,8 +226,19 @@ boost::shared_ptr<ANTLRParserResultBase> Parser::parseAnyOperator(
ANTLRParser parser(lexer);
try {
result = parser.parse_bool_operator(tagset_);
} catch (antlr::MismatchedTokenException &e) {
errors << std::endl
<< "(as bool ) "
<< e.getFileLineColumnString()
<< " " << e.getMessage();
} catch(antlr::NoViableAltException &e) {
errors << std::endl
<< "(as bool ) "
<< e.getFileLineColumnString()
<< " " << e.getMessage();
} catch (antlr::ANTLRException& e) {
errors << "(as predicate) " << e.getMessage() << "\n";
errors << std::endl
<< "(as bool ) " << e.getMessage();
// ignore, try another type
}
}
......@@ -213,8 +249,19 @@ boost::shared_ptr<ANTLRParserResultBase> Parser::parseAnyOperator(
ANTLRParser parser(lexer);
try {
result = parser.parse_position_operator(tagset_);
} catch (antlr::MismatchedTokenException &e) {
errors << std::endl
<< "(as position) "
<< e.getFileLineColumnString()
<< " " << e.getMessage() << std::endl;
} catch(antlr::NoViableAltException &e) {
errors << std::endl
<< "(as position) "
<< e.getFileLineColumnString()
<< " " << e.getMessage() << std::endl;
} catch (antlr::ANTLRException& e) {
errors << "(as position) " << e.getMessage() << "\n";
errors << std::endl
<< "(as position) " << e.getMessage() << std::endl;
// ignore, try another type
}
}
......
#include <cstdlib>
#include <libwccl/values/strset.h>
#include <libwccl/values/bool.h>
#include <libwccl/parser/Parser.h>
#include <libwccl/parser/ANTLRParserResult.h>
#include <antlr/NoViableAltException.hpp>
#include <antlr/MismatchedTokenException.hpp>
// ----------------------------------------------------------------------------
......@@ -53,27 +54,25 @@ int main()
<< std::endl;
}
else {
std::cerr << "Problem while parsing -- "
<< "haven't got StrSet object in boost::shared_ptr!"
<< std::endl;
std::cerr << "Problem while parsing -- Bool is NULL!" << std::endl;
}
}
else {
std::cerr << "Problem while parsing -- "
<< "haven't got Function<Wccl::StrSet> object in "
<< "boost::shared_ptr!" << std::endl;
<< "Function<Wccl::Bool> is NULL!" << std::endl;
}
}
catch (antlr::MismatchedTokenException &e) {
std::cerr << e.getMessage() << std::endl;
}
catch (Wccl::InvalidVariableName &e) {
std::cerr << e.getFileLineColumnString()
<< " " << e.getMessage() << std::endl;
} catch(antlr::NoViableAltException &e) {
std::cerr << e.getFileLineColumnString()
<< " " << e.getMessage() << std::endl;
} catch (Wccl::InvalidVariableName &e) {
std::cerr << "Wccl::InvalidVariableName" << std::endl;
}
catch (Wccl::VariableTypeMismatch &e) {
} catch (Wccl::VariableTypeMismatch &e) {
std::cerr << "Wccl::VariableTypeMismatch" << std::endl;
}
catch (...) {
} catch (...) {
std::cerr << "[N] Syntax error!" << std::endl;
}
}
......
......@@ -11,6 +11,7 @@
#include <boost/program_options.hpp>
#include <libcorpus2/io/xcesreader.h>
#include <antlr/NoViableAltException.hpp>
#include <antlr/MismatchedTokenException.hpp>
// ----------------------------------------------------------------------------
......@@ -145,13 +146,17 @@ bool process_line(const std::string& line, Wccl::Parser& parser,
<< "parser returned NULL!" << std::endl;
}
} catch (antlr::MismatchedTokenException &e) {
std::cerr << e.getMessage() << std::endl;
std::cerr << e.getFileLineColumnString()
<< " " << e.getMessage() << std::endl;
} catch(antlr::NoViableAltException &e) {
std::cerr << e.getFileLineColumnString()
<< " " << e.getMessage() << std::endl;
} catch (Wccl::InvalidVariableName &e) {
std::cerr << "Wccl::InvalidVariableName " << e.info() << std::endl;
} catch (Wccl::VariableTypeMismatch &e) {
std::cerr << "Wccl::VariableTypeMismatch " << e.info() << std::endl;
} catch (Wccl::WcclError& e) {
std::cerr << "Wccl::WcclError " << e.info() << std::endl;
std::cerr << "Wccl::WcclError:" << e.info() << std::endl;
} catch (PwrNlp::PwrNlpError& e) {
std::cerr << "PwrNlp::PwrNlpError " << e.info() << std::endl;
} catch (antlr::ANTLRException& e) {
......
#include <cstdlib>
#include <boost/shared_ptr.hpp>
#include <libwccl/values/strset.h>
#include <libwccl/parser/Parser.h>
#include <libwccl/parser/ANTLRParserResult.h>
#include <antlr/NoViableAltException.hpp>
#include <antlr/MismatchedTokenException.hpp>
// ----------------------------------------------------------------------------
......@@ -54,21 +53,25 @@ int main()
<< std::endl;
}
else {
std::cerr << "Problem while parsing -- "
<< "haven't got StrSet object in boost::shared_ptr!"
<< std::endl;
std::cerr << "Problem while parsing -- StrSet is NULL!" << std::endl;
}
}
else {
std::cerr << "Problem while parsing -- "
<< "haven't got Function<Wccl::StrSet> object in "
<< "boost::shared_ptr!" << std::endl;
<< "Function<Wccl::StrSet> is NULL!" << std::endl;
}
}
catch (antlr::MismatchedTokenException &e) {
std::cerr << e.getMessage() << std::endl;
}
catch (...) {
std::cerr << e.getFileLineColumnString()
<< " " << e.getMessage() << std::endl;
} catch(antlr::NoViableAltException &e) {
std::cerr << e.getFileLineColumnString()
<< " " << e.getMessage() << std::endl;
} catch (Wccl::InvalidVariableName &e) {
std::cerr << "Wccl::InvalidVariableName" << std::endl;
} catch (Wccl::VariableTypeMismatch &e) {
std::cerr << "Wccl::VariableTypeMismatch" << std::endl;
} catch (...) {
std::cerr << "[N] Syntax error!" << std::endl;
}
}
......
#include <cstdlib>
#include <libcorpus2/tagsetmanager.h>
#include <libwccl/values/tset.h>
#include <libwccl/parser/Parser.h>
#include <libwccl/parser/ANTLRParserResult.h>
#include <antlr/NoViableAltException.hpp>
#include <antlr/MismatchedTokenException.hpp>
#include <libcorpus2/tagsetmanager.h>
// ----------------------------------------------------------------------------
/**
......@@ -56,21 +55,25 @@ int main()
<< std::endl;
}
else {
std::cerr << "Problem while parsing -- "
<< "haven't got StrSet object in boost::shared_ptr!"
<< std::endl;
std::cerr << "Problem while parsing -- TSet is NULL!" << std::endl;
}
}
else {
std::cerr << "Problem while parsing -- "
<< "haven't got Function<Wccl::StrSet> object in "
<< "boost::shared_ptr!" << std::endl;
<< "Function<Wccl::TSet> is NULL!" << std::endl;
}
}
catch (antlr::MismatchedTokenException &e) {
std::cerr << e.getMessage() << std::endl;
}
catch (...) {
std::cerr << e.getFileLineColumnString()
<< " " << e.getMessage() << std::endl;
} catch(antlr::NoViableAltException &e) {
std::cerr << e.getFileLineColumnString()
<< " " << e.getMessage() << std::endl;
} catch (Wccl::InvalidVariableName &e) {
std::cerr << "Wccl::InvalidVariableName" << std::endl;
} catch (Wccl::VariableTypeMismatch &e) {
std::cerr << "Wccl::VariableTypeMismatch" << std::endl;
} catch (...) {
std::cerr << "[N] Syntax error!" << std::endl;
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment