summaryrefslogtreecommitdiffstats
path: root/languages/ada/preambles.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit114a878c64ce6f8223cfd22d76a20eb16d177e5e (patch)
treeacaf47eb0fa12142d3896416a69e74cbf5a72242 /languages/ada/preambles.h
downloadtdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.tar.gz
tdevelop-114a878c64ce6f8223cfd22d76a20eb16d177e5e.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdevelop@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'languages/ada/preambles.h')
-rw-r--r--languages/ada/preambles.h89
1 files changed, 89 insertions, 0 deletions
diff --git a/languages/ada/preambles.h b/languages/ada/preambles.h
new file mode 100644
index 00000000..e9ea460b
--- /dev/null
+++ b/languages/ada/preambles.h
@@ -0,0 +1,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_
+