summaryrefslogtreecommitdiff
path: root/src/parser/parser_exception.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser/parser_exception.h')
-rw-r--r--src/parser/parser_exception.h37
1 files changed, 35 insertions, 2 deletions
diff --git a/src/parser/parser_exception.h b/src/parser/parser_exception.h
index f0ddc6a7f..ee02289ee 100644
--- a/src/parser/parser_exception.h
+++ b/src/parser/parser_exception.h
@@ -18,8 +18,9 @@
#include "util/exception.h"
#include "cvc4_config.h"
-#include <string>
#include <iostream>
+#include <string>
+#include <sstream>
namespace CVC4 {
namespace parser {
@@ -30,11 +31,43 @@ public:
ParserException() { }
ParserException(const std::string& msg): Exception(msg) { }
ParserException(const char* msg): Exception(msg) { }
+ ParserException(const std::string& msg, const std::string& filename,
+ unsigned long line, unsigned long column) :
+ Exception(msg),
+ d_filename(filename),
+ d_line(line),
+ d_column(column) {
+ }
+
// Destructor
virtual ~ParserException() throw() {}
virtual std::string toString() const {
- return "Parse Error: " + d_msg;
+ if( d_line > 0 ) {
+ std::stringstream ss;
+ ss << "Parser Error: " << d_filename << ":" << d_line << "."
+ << d_column << ": " << d_msg;
+ return ss.str();
+ } else {
+ return "Parse Error: " + d_msg;
+ }
+ }
+
+ std::string getFilename() const {
+ return d_filename;
}
+
+ int getLine() const {
+ return d_line;
+ }
+
+ int getColumn() const {
+ return d_column;
+ }
+
+protected:
+ std::string d_filename;
+ unsigned long d_line;
+ unsigned long d_column;
}; // end of class ParserException
}/* CVC4::parser namespace */
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback