zenilib: zenilib/jni/external/angle/src/compiler/preprocessor/DiagnosticsBase.cpp Source File

zenilib 0.5.3.0

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DiagnosticsBase.cpp
Go to the documentation of this file.
1 //
2 // Copyright (c) 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 #include "DiagnosticsBase.h"
8
9 #include <cassert>
10
11 namespace pp
12 {
13
14 Diagnostics::~Diagnostics()
15 {
16 }
17
18 void Diagnostics::report(ID id,
19 const SourceLocation& loc,
20 const std::string& text)
21 {
22 // TODO(alokp): Keep a count of errors and warnings.
23 print(id, loc, text);
24 }
25
26 Diagnostics::Severity Diagnostics::severity(ID id)
27 {
28 if ((id > ERROR_BEGIN) && (id < ERROR_END))
29 return ERROR;
30
31 if ((id > WARNING_BEGIN) && (id < WARNING_END))
32 return WARNING;
33
34 assert(false);
35 return ERROR;
36 }
37
38 std::string Diagnostics::message(ID id)
39 {
40 switch (id)
41 {
42 // Errors begin.
43 case INTERNAL_ERROR:
44 return "internal error";
45 case OUT_OF_MEMORY:
46 return "out of memory";
47 case INVALID_CHARACTER:
48 return "invalid character";
49 case INVALID_NUMBER:
50 return "invalid number";
51 case INTEGER_OVERFLOW:
52 return "integer overflow";
53 case FLOAT_OVERFLOW:
54 return "float overflow";
55 case TOKEN_TOO_LONG:
56 return "token too long";
57 case INVALID_EXPRESSION:
58 return "invalid expression";
59 case DIVISION_BY_ZERO:
60 return "division by zero";
61 case EOF_IN_COMMENT:
62 return "unexpected end of file found in comment";
63 case UNEXPECTED_TOKEN:
64 return "unexpected token";
65 case DIRECTIVE_INVALID_NAME:
66 return "invalid directive name";
67 case MACRO_NAME_RESERVED:
68 return "macro name is reserved";
69 case MACRO_REDEFINED:
70 return "macro redefined";
71 case MACRO_PREDEFINED_REDEFINED:
72 return "predefined macro redefined";
73 case MACRO_PREDEFINED_UNDEFINED:
74 return "predefined macro undefined";
75 case MACRO_UNTERMINATED_INVOCATION:
76 return "unterminated macro invocation";
77 case MACRO_TOO_FEW_ARGS:
78 return "Not enough arguments for macro";
79 case MACRO_TOO_MANY_ARGS:
80 return "Too many arguments for macro";
81 case CONDITIONAL_ENDIF_WITHOUT_IF:
82 return "unexpected #endif found without a matching #if";
83 case CONDITIONAL_ELSE_WITHOUT_IF:
84 return "unexpected #else found without a matching #if";
85 case CONDITIONAL_ELSE_AFTER_ELSE:
86 return "unexpected #else found after another #else";
87 case CONDITIONAL_ELIF_WITHOUT_IF:
88 return "unexpected #elif found without a matching #if";
89 case CONDITIONAL_ELIF_AFTER_ELSE:
90 return "unexpected #elif found after #else";
91 case CONDITIONAL_UNTERMINATED:
92 return "unexpected end of file found in conditional block";
93 case INVALID_EXTENSION_NAME:
94 return "invalid extension name";
95 case INVALID_EXTENSION_BEHAVIOR:
96 return "invalid extension behavior";
97 case INVALID_EXTENSION_DIRECTIVE:
98 return "invalid extension directive";
99 case INVALID_VERSION_NUMBER:
100 return "invalid version number";
101 case INVALID_VERSION_DIRECTIVE:
102 return "invalid version directive";
103 case VERSION_NOT_FIRST_STATEMENT:
104 return "#version directive must occur before anything else, "
105 "except for comments and white space";
106 case INVALID_LINE_NUMBER:
107 return "invalid line number";
108 case INVALID_FILE_NUMBER:
109 return "invalid file number";
110 case INVALID_LINE_DIRECTIVE:
111 return "invalid line directive";
112 // Errors end.
113 // Warnings begin.
114 case EOF_IN_DIRECTIVE:
115 return "unexpected end of file found in directive";
116 case CONDITIONAL_UNEXPECTED_TOKEN:
117 return "unexpected token after conditional expression";
118 case UNRECOGNIZED_PRAGMA:
119 return "unrecognized pragma";
120 // Warnings end.
121 default:
122 assert(false);
123 return "";
124 }
125 }
126
127 } // namespace pp
pp::Diagnostics::CONDITIONAL_ELIF_WITHOUT_IF
Definition: DiagnosticsBase.h:52
pp::Diagnostics::~Diagnostics
virtual ~Diagnostics()
Definition: DiagnosticsBase.cpp:14
pp::Diagnostics::WARNING_BEGIN
Definition: DiagnosticsBase.h:66
pp::Diagnostics::EOF_IN_DIRECTIVE
Definition: DiagnosticsBase.h:67
pp::Diagnostics::INVALID_NUMBER
Definition: DiagnosticsBase.h:33
pp::Diagnostics::ERROR_END
Definition: DiagnosticsBase.h:64
pp::Diagnostics::MACRO_NAME_RESERVED
Definition: DiagnosticsBase.h:42
pp::Diagnostics::INVALID_EXTENSION_DIRECTIVE
Definition: DiagnosticsBase.h:57
pp::Diagnostics::MACRO_REDEFINED
Definition: DiagnosticsBase.h:43
pp::Diagnostics::INVALID_LINE_NUMBER
Definition: DiagnosticsBase.h:61
pp
png_sPLT_entryp pp
Definition: pngrutil.c:1375
pp::Diagnostics::INVALID_FILE_NUMBER
Definition: DiagnosticsBase.h:62
pp::Diagnostics::DIRECTIVE_INVALID_NAME
Definition: DiagnosticsBase.h:41
pp::Diagnostics::INTEGER_OVERFLOW
Definition: DiagnosticsBase.h:34
assert
#define assert(x)
Definition: SDL_malloc.c:1234
pp::Diagnostics::INVALID_EXPRESSION
Definition: DiagnosticsBase.h:37
pp::Diagnostics::WARNING
Definition: DiagnosticsBase.h:25
pp::Diagnostics::INVALID_LINE_DIRECTIVE
Definition: DiagnosticsBase.h:63
DiagnosticsBase.h
pp::Diagnostics::CONDITIONAL_UNEXPECTED_TOKEN
Definition: DiagnosticsBase.h:68
pp::Diagnostics::UNRECOGNIZED_PRAGMA
Definition: DiagnosticsBase.h:69
pp::Diagnostics::CONDITIONAL_ELIF_AFTER_ELSE
Definition: DiagnosticsBase.h:53
pp::Diagnostics::INVALID_CHARACTER
Definition: DiagnosticsBase.h:32
pp::Diagnostics::INVALID_VERSION_NUMBER
Definition: DiagnosticsBase.h:58
pp::Diagnostics::UNEXPECTED_TOKEN
Definition: DiagnosticsBase.h:40
pp::Diagnostics::ERROR
Definition: DiagnosticsBase.h:24
pp::Diagnostics::CONDITIONAL_ELSE_AFTER_ELSE
Definition: DiagnosticsBase.h:51
pp::Diagnostics::MACRO_UNTERMINATED_INVOCATION
Definition: DiagnosticsBase.h:46
pp::Diagnostics::CONDITIONAL_ENDIF_WITHOUT_IF
Definition: DiagnosticsBase.h:49
pp::Diagnostics::EOF_IN_COMMENT
Definition: DiagnosticsBase.h:39
pp::Diagnostics::MACRO_TOO_MANY_ARGS
Definition: DiagnosticsBase.h:48
pp::Diagnostics::report
void report(ID id, const SourceLocation &loc, const std::string &text)
Definition: DiagnosticsBase.cpp:18
pp::Diagnostics::WARNING_END
Definition: DiagnosticsBase.h:70
pp::Diagnostics::print
virtual void print(ID id, const SourceLocation &loc, const std::string &text)=0
pp::Diagnostics::MACRO_PREDEFINED_UNDEFINED
Definition: DiagnosticsBase.h:45
pp::Diagnostics::ERROR_BEGIN
Definition: DiagnosticsBase.h:29
pp::Diagnostics::FLOAT_OVERFLOW
Definition: DiagnosticsBase.h:35
string
GLsizei const GLcharARB ** string
Definition: glew.h:5638
pp::Diagnostics::message
std::string message(ID id)
Definition: DiagnosticsBase.cpp:38
pp::Diagnostics::TOKEN_TOO_LONG
Definition: DiagnosticsBase.h:36
pp::Diagnostics::DIVISION_BY_ZERO
Definition: DiagnosticsBase.h:38
pp::Diagnostics::MACRO_PREDEFINED_REDEFINED
Definition: DiagnosticsBase.h:44
pp::Diagnostics::severity
Severity severity(ID id)
Definition: DiagnosticsBase.cpp:26
pp::Diagnostics::CONDITIONAL_UNTERMINATED
Definition: DiagnosticsBase.h:54
pp::Diagnostics::INVALID_VERSION_DIRECTIVE
Definition: DiagnosticsBase.h:59
pp::Diagnostics::ID
ID
Definition: DiagnosticsBase.h:27
pp::Diagnostics::INVALID_EXTENSION_BEHAVIOR
Definition: DiagnosticsBase.h:56
pp::Diagnostics::OUT_OF_MEMORY
Definition: DiagnosticsBase.h:31
pp::Diagnostics::CONDITIONAL_ELSE_WITHOUT_IF
Definition: DiagnosticsBase.h:50
pp::Diagnostics::MACRO_TOO_FEW_ARGS
Definition: DiagnosticsBase.h:47
pp::SourceLocation
Definition: SourceLocation.h:13
pp::Diagnostics::INTERNAL_ERROR
Definition: DiagnosticsBase.h:30
pp::Diagnostics::INVALID_EXTENSION_NAME
Definition: DiagnosticsBase.h:55
pp::Diagnostics::Severity
Severity
Definition: DiagnosticsBase.h:22
pp::Diagnostics::VERSION_NOT_FIRST_STATEMENT
Definition: DiagnosticsBase.h:60