• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2012 The ANGLE Project Authors. All rights reserved.
3 // Use of this source code is governed by a BSD-style license that can be
4 // found in the LICENSE file.
5 //
6 
7 #ifndef COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_
8 #define COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_
9 
10 #include <string>
11 
12 namespace angle
13 {
14 
15 namespace pp
16 {
17 
18 struct SourceLocation;
19 
20 // Base class for reporting diagnostic messages.
21 // Derived classes are responsible for formatting and printing the messages.
22 class Diagnostics
23 {
24   public:
25     enum ID
26     {
27         PP_ERROR_BEGIN,
28         PP_INTERNAL_ERROR,
29         PP_OUT_OF_MEMORY,
30         PP_INVALID_CHARACTER,
31         PP_INVALID_NUMBER,
32         PP_INTEGER_OVERFLOW,
33         PP_FLOAT_OVERFLOW,
34         PP_TOKEN_TOO_LONG,
35         PP_INVALID_EXPRESSION,
36         PP_DIVISION_BY_ZERO,
37         PP_EOF_IN_COMMENT,
38         PP_UNEXPECTED_TOKEN,
39         PP_DIRECTIVE_INVALID_NAME,
40         PP_MACRO_NAME_RESERVED,
41         PP_MACRO_REDEFINED,
42         PP_MACRO_PREDEFINED_REDEFINED,
43         PP_MACRO_PREDEFINED_UNDEFINED,
44         PP_MACRO_UNTERMINATED_INVOCATION,
45         PP_MACRO_UNDEFINED_WHILE_INVOKED,
46         PP_MACRO_TOO_FEW_ARGS,
47         PP_MACRO_TOO_MANY_ARGS,
48         PP_MACRO_DUPLICATE_PARAMETER_NAMES,
49         PP_MACRO_INVOCATION_CHAIN_TOO_DEEP,
50         PP_CONDITIONAL_ENDIF_WITHOUT_IF,
51         PP_CONDITIONAL_ELSE_WITHOUT_IF,
52         PP_CONDITIONAL_ELSE_AFTER_ELSE,
53         PP_CONDITIONAL_ELIF_WITHOUT_IF,
54         PP_CONDITIONAL_ELIF_AFTER_ELSE,
55         PP_CONDITIONAL_UNTERMINATED,
56         PP_CONDITIONAL_UNEXPECTED_TOKEN,
57         PP_INVALID_EXTENSION_NAME,
58         PP_INVALID_EXTENSION_BEHAVIOR,
59         PP_INVALID_EXTENSION_DIRECTIVE,
60         PP_INVALID_VERSION_NUMBER,
61         PP_INVALID_VERSION_DIRECTIVE,
62         PP_VERSION_NOT_FIRST_STATEMENT,
63         PP_VERSION_NOT_FIRST_LINE_ESSL3,
64         PP_INVALID_LINE_NUMBER,
65         PP_INVALID_FILE_NUMBER,
66         PP_INVALID_LINE_DIRECTIVE,
67     // This is just a warning on CHROME OS http://anglebug.com/4023
68 #if !defined(ANGLE_PLATFORM_CHROMEOS)
69         PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
70 #endif
71         PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL3,
72         PP_UNDEFINED_SHIFT,
73         PP_TOKENIZER_ERROR,
74         PP_ERROR_END,
75 
76         PP_WARNING_BEGIN,
77         PP_EOF_IN_DIRECTIVE,
78         PP_UNRECOGNIZED_PRAGMA,
79 #if defined(ANGLE_PLATFORM_CHROMEOS)
80         PP_NON_PP_TOKEN_BEFORE_EXTENSION_ESSL1,
81 #endif
82         PP_NON_PP_TOKEN_BEFORE_EXTENSION_WEBGL,
83         PP_WARNING_MACRO_NAME_RESERVED,
84         PP_WARNING_END
85     };
86 
87     virtual ~Diagnostics();
88 
89     void report(ID id, const SourceLocation &loc, const std::string &text);
90 
91   protected:
92     bool isError(ID id);
93     const char *message(ID id);
94 
95     virtual void print(ID id, const SourceLocation &loc, const std::string &text) = 0;
96 };
97 
98 }  // namespace pp
99 
100 }  // namespace angle
101 
102 #endif  // COMPILER_PREPROCESSOR_DIAGNOSTICSBASE_H_
103