OpenMD 3.1
Molecular Dynamics in the Open
Loading...
Searching...
No Matches
RecognitionException.cpp
1/* ANTLR Translator Generator
2 * Project led by Terence Parr at http://www.jGuru.com
3 * Software rights: http://www.antlr.org/license.html
4 *
5 * $Id$
6 */
7
8#include "antlr/RecognitionException.hpp"
9#include "antlr/String.hpp"
10
11#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
12namespace antlr {
13#endif
14
15RecognitionException::RecognitionException()
16: ANTLRException("parsing error")
17, line(-1)
18, column(-1)
19{
20}
21
22RecognitionException::RecognitionException(const ANTLR_USE_NAMESPACE(std)string& s)
23: ANTLRException(s)
24, line(-1)
25, column(-1)
26{
27}
28
29RecognitionException::RecognitionException(const ANTLR_USE_NAMESPACE(std)string& s,
30 const ANTLR_USE_NAMESPACE(std)string& fileName_,
31 int line_,int column_)
32: ANTLRException(s)
33, fileName(fileName_)
34, line(line_)
35, column(column_)
36{
37}
38
39ANTLR_USE_NAMESPACE(std)string RecognitionException::getFileLineColumnString() const
40{
41 ANTLR_USE_NAMESPACE(std)string fileLineColumnString;
42
43 if ( fileName.length() > 0 )
44 fileLineColumnString = fileName + ":";
45
46 if ( line != -1 )
47 {
48 if ( fileName.length() == 0 )
49 fileLineColumnString = fileLineColumnString + "line ";
50
51 fileLineColumnString = fileLineColumnString + line;
52
53 if ( column != -1 )
54 fileLineColumnString = fileLineColumnString + ":" + column;
55
56 fileLineColumnString = fileLineColumnString + ":";
57 }
58
59 fileLineColumnString = fileLineColumnString + " ";
60
61 return fileLineColumnString;
62}
63
64ANTLR_USE_NAMESPACE(std)string RecognitionException::toString() const
65{
66 return getFileLineColumnString()+getMessage();
67}
68
69#ifdef ANTLR_CXX_SUPPORTS_NAMESPACE
70}
71#endif