summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/preprocessor/DiagnosticsBase.h
blob: a0899203f780aa47b829cfe0d7d4dd40e3ce464e (plain)
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
90
91
92
93
94
//
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

#ifndef COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_
#define COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_

#include <string>

namespace pp
{

struct SourceLocation;

// Base class for reporting diagnostic messages.
// Derived classes are responsible for formatting and printing the messages.
class Diagnostics
{
  public:
    enum Severity
    {
        PP_ERROR,
        PP_WARNING
    };
    enum ID
    {
        PP_ERROR_BEGIN,
        PP_INTERNAL_ERROR,
        PP_OUT_OF_MEMORY,
        PP_INVALID_CHARACTER,
        PP_INVALID_NUMBER,
        PP_INTEGER_OVERFLOW,
        PP_FLOAT_OVERFLOW,
        PP_TOKEN_TOO_LONG,
        PP_INVALID_EXPRESSION,
        PP_DIVISION_BY_ZERO,
        PP_EOF_IN_COMMENT,
        PP_UNEXPECTED_TOKEN,
        PP_DIRECTIVE_INVALID_NAME,
        PP_MACRO_NAME_RESERVED,
        PP_MACRO_REDEFINED,
        PP_MACRO_PREDEFINED_REDEFINED,
        PP_MACRO_PREDEFINED_UNDEFINED,
        PP_MACRO_UNTERMINATED_INVOCATION,
        PP_MACRO_TOO_FEW_ARGS,
        PP_MACRO_TOO_MANY_ARGS,
        PP_MACRO_DUPLICATE_PARAMETER_NAMES,
        PP_CONDITIONAL_ENDIF_WITHOUT_IF,
        PP_CONDITIONAL_ELSE_WITHOUT_IF,
        PP_CONDITIONAL_ELSE_AFTER_ELSE,
        PP_CONDITIONAL_ELIF_WITHOUT_IF,
        PP_CONDITIONAL_ELIF_AFTER_ELSE,
        PP_CONDITIONAL_UNTERMINATED,
        PP_CONDITIONAL_UNEXPECTED_TOKEN,
        PP_INVALID_EXTENSION_NAME,
        PP_INVALID_EXTENSION_BEHAVIOR,
        PP_INVALID_EXTENSION_DIRECTIVE,
        PP_INVALID_VERSION_NUMBER,
        PP_INVALID_VERSION_DIRECTIVE,
        PP_VERSION_NOT_FIRST_STATEMENT,
        PP_VERSION_NOT_FIRST_LINE_ESSL3,
        PP_INVALID_LINE_NUMBER,
        PP_INVALID_FILE_NUMBER,
        PP_INVALID_LINE_DIRECTIVE,
        PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3,
        PP_UNDEFINED_SHIFT,
        PP_ERROR_END,

        PP_WARNING_BEGIN,
        PP_EOF_IN_DIRECTIVE,
        PP_UNRECOGNIZED_PRAGMA,
        PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
        PP_WARNING_MACRO_NAME_RESERVED,
        PP_WARNING_END
    };

    virtual ~Diagnostics();

    void report(ID id, const SourceLocation &loc, const std::string &text);

  protected:
    Severity severity(ID id);
    std::string message(ID id);

    virtual void print(ID id,
                       const SourceLocation &loc,
                       const std::string &text) = 0;
};

}  // namespace pp

#endif  // COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_