blob: 9c185ccc8cc33d8e81dbc6df56b7ba831a2e5138 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
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
|