diff options
author | Christopher L. Conway <christopherleeconway@gmail.com> | 2010-03-30 20:22:33 +0000 |
---|---|---|
committer | Christopher L. Conway <christopherleeconway@gmail.com> | 2010-03-30 20:22:33 +0000 |
commit | 8730e9320a833a9eb0e65074f9988950b7424c0c (patch) | |
tree | 1cb09404256743e208fece079ba473595e05edcd /src/parser/parser_exception.h | |
parent | 8c87c05ac56a5f29b2ae1e658f2d7d3b7b588163 (diff) |
Merging from branches/antlr3 (r246:354)
Diffstat (limited to 'src/parser/parser_exception.h')
-rw-r--r-- | src/parser/parser_exception.h | 37 |
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 */ |