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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*
* Two macros are defined here: ANTLR_PARSER_PREAMBLE and ANTLR_LEXER_PREAMBLE.
* They encapsulate the application specific extensions for the classes
* AdaParser and AdaLexer which are defined in ada.g.
* This keeps ada.g independent of the application.
*
* Kdevelop version:
* (C) 2003 Oliver M. Kellogg (okellogg@users.sourceforge.net)
*/
#ifndef _PREAMBLES_H_
#define _PREAMBLES_H_
#include <string>
#include "problemreporter.h"
#define ANTLR_PARSER_PREAMBLE \
private: \
unsigned int m_numberOfErrors; \
ProblemReporter* m_problemReporter; \
\
public: \
void resetErrors () { m_numberOfErrors = 0; } \
unsigned int numberOfErrors () const { return m_numberOfErrors; } \
void setProblemReporter (ProblemReporter* r) { m_problemReporter = r; } \
\
void reportError (const antlr::RecognitionException& ex) { \
m_problemReporter->reportError \
(ex.toString().c_str (), \
ex.getFilename().c_str (), \
ex.getLine (), \
ex.getColumn ()); \
++m_numberOfErrors; \
} \
\
void reportError (const std::string& errorMessage) { \
m_problemReporter->reportError \
(errorMessage.c_str(), \
getFilename ().c_str(), \
LT(1)->getLine (), \
LT(1)->getColumn ()); \
++m_numberOfErrors; \
} \
\
void reportMessage (const std::string& message) { \
m_problemReporter->reportMessage \
(message.c_str (), \
getFilename ().c_str (), \
LT(1)->getLine (), \
LT(1)->getColumn ()); \
}
#define ANTLR_LEXER_PREAMBLE \
private: \
unsigned int m_numberOfErrors; \
ProblemReporter* m_problemReporter; \
\
public: \
void resetErrors () { m_numberOfErrors = 0; } \
unsigned int numberOfErrors () const { return m_numberOfErrors; } \
void setProblemReporter (ProblemReporter* r) { m_problemReporter = r; } \
\
void reportError (const antlr::RecognitionException& ex) { \
m_problemReporter->reportError \
(ex.toString ().c_str (), \
ex.getFilename ().c_str (), \
ex.getLine (), \
ex.getColumn ()); \
++m_numberOfErrors; \
} \
\
void reportError (const std::string& errorMessage) { \
m_problemReporter->reportError \
(errorMessage.c_str (), \
getFilename().c_str (), \
getLine (), \
getColumn ()); \
++m_numberOfErrors; \
} \
\
void reportWarning (const std::string& warnMessage) { \
m_problemReporter->reportWarning \
(warnMessage.c_str (), \
getFilename ().c_str (), \
getLine (), \
getColumn ()); \
}
#endif // _PREAMBLES_H_
|