michael@0: // michael@0: // Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: #ifndef COMPILER_PREPROCESSOR_DIAGNOSTICS_H_ michael@0: #define COMPILER_PREPROCESSOR_DIAGNOSTICS_H_ michael@0: michael@0: #include michael@0: michael@0: // Windows.h #defines ERROR. michael@0: #ifdef ERROR michael@0: #undef ERROR michael@0: #endif michael@0: michael@0: namespace pp michael@0: { michael@0: michael@0: struct SourceLocation; michael@0: michael@0: // Base class for reporting diagnostic messages. michael@0: // Derived classes are responsible for formatting and printing the messages. michael@0: class Diagnostics michael@0: { michael@0: public: michael@0: enum Severity michael@0: { michael@0: ERROR, michael@0: WARNING michael@0: }; michael@0: enum ID michael@0: { michael@0: ERROR_BEGIN, michael@0: INTERNAL_ERROR, michael@0: OUT_OF_MEMORY, michael@0: INVALID_CHARACTER, michael@0: INVALID_NUMBER, michael@0: INTEGER_OVERFLOW, michael@0: FLOAT_OVERFLOW, michael@0: TOKEN_TOO_LONG, michael@0: INVALID_EXPRESSION, michael@0: DIVISION_BY_ZERO, michael@0: EOF_IN_COMMENT, michael@0: UNEXPECTED_TOKEN, michael@0: DIRECTIVE_INVALID_NAME, michael@0: MACRO_NAME_RESERVED, michael@0: MACRO_REDEFINED, michael@0: MACRO_PREDEFINED_REDEFINED, michael@0: MACRO_PREDEFINED_UNDEFINED, michael@0: MACRO_UNTERMINATED_INVOCATION, michael@0: MACRO_TOO_FEW_ARGS, michael@0: MACRO_TOO_MANY_ARGS, michael@0: CONDITIONAL_ENDIF_WITHOUT_IF, michael@0: CONDITIONAL_ELSE_WITHOUT_IF, michael@0: CONDITIONAL_ELSE_AFTER_ELSE, michael@0: CONDITIONAL_ELIF_WITHOUT_IF, michael@0: CONDITIONAL_ELIF_AFTER_ELSE, michael@0: CONDITIONAL_UNTERMINATED, michael@0: INVALID_EXTENSION_NAME, michael@0: INVALID_EXTENSION_BEHAVIOR, michael@0: INVALID_EXTENSION_DIRECTIVE, michael@0: INVALID_VERSION_NUMBER, michael@0: INVALID_VERSION_DIRECTIVE, michael@0: VERSION_NOT_FIRST_STATEMENT, michael@0: INVALID_LINE_NUMBER, michael@0: INVALID_FILE_NUMBER, michael@0: INVALID_LINE_DIRECTIVE, michael@0: ERROR_END, michael@0: michael@0: WARNING_BEGIN, michael@0: EOF_IN_DIRECTIVE, michael@0: CONDITIONAL_UNEXPECTED_TOKEN, michael@0: UNRECOGNIZED_PRAGMA, michael@0: WARNING_END michael@0: }; michael@0: michael@0: virtual ~Diagnostics(); michael@0: michael@0: void report(ID id, const SourceLocation& loc, const std::string& text); michael@0: michael@0: protected: michael@0: Severity severity(ID id); michael@0: std::string message(ID id); michael@0: michael@0: virtual void print(ID id, michael@0: const SourceLocation& loc, michael@0: const std::string& text) = 0; michael@0: }; michael@0: michael@0: } // namespace pp michael@0: #endif // COMPILER_PREPROCESSOR_DIAGNOSTICS_H_