KDevelop API Documentation

preambles.h

Go to the documentation of this file.
00001 /* $Id: preambles.h,v 1.1 2003/08/02 19:58:22 okellogg Exp $
00002  *
00003  * Two macros are defined here: ANTLR_PARSER_PREAMBLE and ANTLR_LEXER_PREAMBLE.
00004  * They encapsulate the application specific extensions for the classes
00005  * AdaParser and AdaLexer which are defined in ada.g.
00006  * This keeps ada.g independent of the application.
00007  *
00008  * Kdevelop version:
00009  * (C) 2003  Oliver M. Kellogg  (okellogg@users.sourceforge.net)
00010  */
00011 #ifndef _PREAMBLES_H_
00012 #define _PREAMBLES_H_
00013 
00014 #include <string>
00015 #include "problemreporter.h"
00016 
00017 #define ANTLR_PARSER_PREAMBLE  \
00018   private:                                                                    \
00019     unsigned int m_numberOfErrors;                                            \
00020     ProblemReporter* m_problemReporter;                                       \
00021                                                                               \
00022   public:                                                                     \
00023     void resetErrors ()                          { m_numberOfErrors = 0; }    \
00024     unsigned int numberOfErrors () const         { return m_numberOfErrors; } \
00025     void setProblemReporter (ProblemReporter* r) { m_problemReporter = r; }   \
00026                                                                               \
00027     void reportError (const antlr::RecognitionException& ex) {                \
00028       m_problemReporter->reportError                                          \
00029              (ex.toString().c_str (),                                         \
00030               ex.getFilename().c_str (),                                      \
00031               ex.getLine (),                                                  \
00032               ex.getColumn ());                                               \
00033       ++m_numberOfErrors;                                                     \
00034     }                                                                         \
00035                                                                               \
00036     void reportError (const std::string& errorMessage) {                      \
00037       m_problemReporter->reportError                                          \
00038              (errorMessage.c_str(),                                           \
00039               getFilename ().c_str(),                                         \
00040               LT(1)->getLine (),                                              \
00041               LT(1)->getColumn ());                                           \
00042       ++m_numberOfErrors;                                                     \
00043     }                                                                         \
00044                                                                               \
00045     void reportMessage (const std::string& message) {                         \
00046       m_problemReporter->reportMessage                                        \
00047              (message.c_str (),                                               \
00048               getFilename ().c_str (),                                        \
00049               LT(1)->getLine (),                                              \
00050               LT(1)->getColumn ());                                           \
00051     }
00052 
00053 #define ANTLR_LEXER_PREAMBLE  \
00054   private:                                                                    \
00055     unsigned int m_numberOfErrors;                                            \
00056     ProblemReporter* m_problemReporter;                                       \
00057                                                                               \
00058   public:                                                                     \
00059     void resetErrors ()                          { m_numberOfErrors = 0; }    \
00060     unsigned int numberOfErrors () const         { return m_numberOfErrors; } \
00061     void setProblemReporter (ProblemReporter* r) { m_problemReporter = r; }   \
00062                                                                               \
00063     void reportError (const antlr::RecognitionException& ex) {                \
00064       m_problemReporter->reportError                                          \
00065              (ex.toString ().c_str (),                                        \
00066               ex.getFilename ().c_str (),                                     \
00067               ex.getLine (),                                                  \
00068               ex.getColumn ());                                               \
00069       ++m_numberOfErrors;                                                     \
00070     }                                                                         \
00071                                                                               \
00072     void reportError (const std::string& errorMessage) {                      \
00073       m_problemReporter->reportError                                          \
00074              (errorMessage.c_str (),                                          \
00075               getFilename().c_str (),                                         \
00076               getLine (),                                                     \
00077               getColumn ());                                                  \
00078       ++m_numberOfErrors;                                                     \
00079     }                                                                         \
00080                                                                               \
00081     void reportWarning (const std::string& warnMessage) {                     \
00082       m_problemReporter->reportWarning                                        \
00083              (warnMessage.c_str (),                                           \
00084               getFilename ().c_str (),                                        \
00085               getLine (),                                                     \
00086               getColumn ());                                                  \
00087     }
00088 
00089 #endif  // _PREAMBLES_H_
00090 
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:45 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003