summaryrefslogtreecommitdiffstats
path: root/lib/antlr/src/RecognitionException.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/antlr/src/RecognitionException.cpp')
-rw-r--r--lib/antlr/src/RecognitionException.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/lib/antlr/src/RecognitionException.cpp b/lib/antlr/src/RecognitionException.cpp
new file mode 100644
index 00000000..9c185ccc
--- /dev/null
+++ b/lib/antlr/src/RecognitionException.cpp
@@ -0,0 +1,71 @@
+/* ANTLR Translator Generator
+ * Project led by Terence Parr at http://www.jGuru.com
+ * Software rights: http://www.antlr.org/license.html
+ *
+ * $Id$
+ */
+
+#include "antlr/RecognitionException.hpp"
+#include "antlr/String.hpp"
+
+#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
+namespace antlr {
+#endif
+
+RecognitionException::RecognitionException()
+: ANTLRException("parsing error")
+, line(-1)
+, column(-1)
+{
+}
+
+RecognitionException::RecognitionException(const ANTLR_USE_NAMESPACE(std)string& s)
+: ANTLRException(s)
+, line(-1)
+, column(-1)
+{
+}
+
+RecognitionException::RecognitionException(const ANTLR_USE_NAMESPACE(std)string& s,
+ const ANTLR_USE_NAMESPACE(std)string& fileName_,
+ int line_,int column_)
+: ANTLRException(s)
+, fileName(fileName_)
+, line(line_)
+, column(column_)
+{
+}
+
+ANTLR_USE_NAMESPACE(std)string RecognitionException::getFileLineColumnString() const
+{
+ ANTLR_USE_NAMESPACE(std)string fileLineColumnString;
+
+ if ( fileName.length() > 0 )
+ fileLineColumnString = fileName + ":";
+
+ if ( line != -1 )
+ {
+ if ( fileName.length() == 0 )
+ fileLineColumnString = fileLineColumnString + "line ";
+
+ fileLineColumnString = fileLineColumnString + line;
+
+ if ( column != -1 )
+ fileLineColumnString = fileLineColumnString + ":" + column;
+
+ fileLineColumnString = fileLineColumnString + ":";
+ }
+
+ fileLineColumnString = fileLineColumnString + " ";
+
+ return fileLineColumnString;
+}
+
+ANTLR_USE_NAMESPACE(std)string RecognitionException::toString() const
+{
+ return getFileLineColumnString()+getMessage();
+}
+
+#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
+}
+#endif