OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
errorhandler.hpp
Go to the documentation of this file.
1 #ifndef COMPILER_ERRORHANDLER_H_INCLUDED
2 #define COMPILER_ERRORHANDLER_H_INCLUDED
3 
4 #include <string>
5 
6 namespace Compiler
7 {
8  struct TokenLoc;
9 
13 
15  {
16  int mWarnings;
17  int mErrors;
20 
21  protected:
22 
23  enum Type
24  {
26  };
27 
28  private:
29 
30  // mutators
31 
32  virtual void report (const std::string& message, const TokenLoc& loc, Type type) = 0;
34 
35  virtual void report (const std::string& message, Type type) = 0;
37 
38  public:
39 
40  ErrorHandler();
42 
43  virtual ~ErrorHandler();
45 
46  bool isGood() const;
48 
49  int countErrors() const;
51 
52  int countWarnings() const;
54 
55  void warning (const std::string& message, const TokenLoc& loc);
57 
58  void error (const std::string& message, const TokenLoc& loc);
60 
61  void endOfFile();
63 
64  virtual void reset();
66 
67  void setWarningsMode (int mode);
69 
71  void downgradeErrors (bool downgrade);
72  };
73 
75  {
77 
80 
83 
84  public:
85 
86  ErrorDowngrade (ErrorHandler& handler);
87 
89  };
90 }
91 
92 #endif
Type
Definition: errorhandler.hpp:23
void error(const std::string &message, const TokenLoc &loc)
Generate an error message.
Definition: errorhandler.cpp:49
void message(CodeContainer &code, Literals &literals, const std::string &message, int buttons)
Definition: generator.cpp:537
int mWarningsMode
Definition: errorhandler.hpp:18
int countWarnings() const
Return number of warnings.
Definition: errorhandler.cpp:26
Location of a token in a source file.
Definition: tokenloc.hpp:10
void setWarningsMode(int mode)
// 0 ignore, 1 rate as warning, 2 rate as error
Definition: errorhandler.cpp:76
Definition: errorhandler.hpp:25
virtual void reset()
Remove all previous error/warning events.
Definition: errorhandler.cpp:71
ErrorDowngrade(const ErrorDowngrade &)
not implemented
virtual ~ErrorHandler()
destructor
Definition: errorhandler.cpp:8
void downgradeErrors(bool downgrade)
Treat errors as warnings.
Definition: errorhandler.cpp:81
void warning(const std::string &message, const TokenLoc &loc)
Generate a warning message.
Definition: errorhandler.cpp:33
Error handling.
Definition: errorhandler.hpp:14
int mWarnings
Definition: errorhandler.hpp:16
ErrorDowngrade & operator=(const ErrorDowngrade &)
not implemented
Definition: errorhandler.hpp:74
Definition: errorhandler.hpp:25
virtual void report(const std::string &message, const TokenLoc &loc, Type type)=0
Report error to the user.
ErrorHandler & mHandler
Definition: errorhandler.hpp:76
bool isGood() const
Was compiling successful?
Definition: errorhandler.cpp:12
~ErrorDowngrade()
Definition: errorhandler.cpp:92
void endOfFile()
Generate an error message for an unexpected EOF.
Definition: errorhandler.cpp:63
int countErrors() const
Return number of errors.
Definition: errorhandler.cpp:19
ErrorHandler()
constructor
Definition: errorhandler.cpp:5
bool mDowngradeErrors
Definition: errorhandler.hpp:19
int mErrors
Definition: errorhandler.hpp:17