1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/gfx/angle/src/compiler/preprocessor/DiagnosticsBase.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,127 @@ 1.4 +// 1.5 +// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved. 1.6 +// Use of this source code is governed by a BSD-style license that can be 1.7 +// found in the LICENSE file. 1.8 +// 1.9 + 1.10 +#include "DiagnosticsBase.h" 1.11 + 1.12 +#include <cassert> 1.13 + 1.14 +namespace pp 1.15 +{ 1.16 + 1.17 +Diagnostics::~Diagnostics() 1.18 +{ 1.19 +} 1.20 + 1.21 +void Diagnostics::report(ID id, 1.22 + const SourceLocation& loc, 1.23 + const std::string& text) 1.24 +{ 1.25 + // TODO(alokp): Keep a count of errors and warnings. 1.26 + print(id, loc, text); 1.27 +} 1.28 + 1.29 +Diagnostics::Severity Diagnostics::severity(ID id) 1.30 +{ 1.31 + if ((id > ERROR_BEGIN) && (id < ERROR_END)) 1.32 + return ERROR; 1.33 + 1.34 + if ((id > WARNING_BEGIN) && (id < WARNING_END)) 1.35 + return WARNING; 1.36 + 1.37 + assert(false); 1.38 + return ERROR; 1.39 +} 1.40 + 1.41 +std::string Diagnostics::message(ID id) 1.42 +{ 1.43 + switch (id) 1.44 + { 1.45 + // Errors begin. 1.46 + case INTERNAL_ERROR: 1.47 + return "internal error"; 1.48 + case OUT_OF_MEMORY: 1.49 + return "out of memory"; 1.50 + case INVALID_CHARACTER: 1.51 + return "invalid character"; 1.52 + case INVALID_NUMBER: 1.53 + return "invalid number"; 1.54 + case INTEGER_OVERFLOW: 1.55 + return "integer overflow"; 1.56 + case FLOAT_OVERFLOW: 1.57 + return "float overflow"; 1.58 + case TOKEN_TOO_LONG: 1.59 + return "token too long"; 1.60 + case INVALID_EXPRESSION: 1.61 + return "invalid expression"; 1.62 + case DIVISION_BY_ZERO: 1.63 + return "division by zero"; 1.64 + case EOF_IN_COMMENT: 1.65 + return "unexpected end of file found in comment"; 1.66 + case UNEXPECTED_TOKEN: 1.67 + return "unexpected token"; 1.68 + case DIRECTIVE_INVALID_NAME: 1.69 + return "invalid directive name"; 1.70 + case MACRO_NAME_RESERVED: 1.71 + return "macro name is reserved"; 1.72 + case MACRO_REDEFINED: 1.73 + return "macro redefined"; 1.74 + case MACRO_PREDEFINED_REDEFINED: 1.75 + return "predefined macro redefined"; 1.76 + case MACRO_PREDEFINED_UNDEFINED: 1.77 + return "predefined macro undefined"; 1.78 + case MACRO_UNTERMINATED_INVOCATION: 1.79 + return "unterminated macro invocation"; 1.80 + case MACRO_TOO_FEW_ARGS: 1.81 + return "Not enough arguments for macro"; 1.82 + case MACRO_TOO_MANY_ARGS: 1.83 + return "Too many arguments for macro"; 1.84 + case CONDITIONAL_ENDIF_WITHOUT_IF: 1.85 + return "unexpected #endif found without a matching #if"; 1.86 + case CONDITIONAL_ELSE_WITHOUT_IF: 1.87 + return "unexpected #else found without a matching #if"; 1.88 + case CONDITIONAL_ELSE_AFTER_ELSE: 1.89 + return "unexpected #else found after another #else"; 1.90 + case CONDITIONAL_ELIF_WITHOUT_IF: 1.91 + return "unexpected #elif found without a matching #if"; 1.92 + case CONDITIONAL_ELIF_AFTER_ELSE: 1.93 + return "unexpected #elif found after #else"; 1.94 + case CONDITIONAL_UNTERMINATED: 1.95 + return "unexpected end of file found in conditional block"; 1.96 + case INVALID_EXTENSION_NAME: 1.97 + return "invalid extension name"; 1.98 + case INVALID_EXTENSION_BEHAVIOR: 1.99 + return "invalid extension behavior"; 1.100 + case INVALID_EXTENSION_DIRECTIVE: 1.101 + return "invalid extension directive"; 1.102 + case INVALID_VERSION_NUMBER: 1.103 + return "invalid version number"; 1.104 + case INVALID_VERSION_DIRECTIVE: 1.105 + return "invalid version directive"; 1.106 + case VERSION_NOT_FIRST_STATEMENT: 1.107 + return "#version directive must occur before anything else, " 1.108 + "except for comments and white space"; 1.109 + case INVALID_LINE_NUMBER: 1.110 + return "invalid line number"; 1.111 + case INVALID_FILE_NUMBER: 1.112 + return "invalid file number"; 1.113 + case INVALID_LINE_DIRECTIVE: 1.114 + return "invalid line directive"; 1.115 + // Errors end. 1.116 + // Warnings begin. 1.117 + case EOF_IN_DIRECTIVE: 1.118 + return "unexpected end of file found in directive"; 1.119 + case CONDITIONAL_UNEXPECTED_TOKEN: 1.120 + return "unexpected token after conditional expression"; 1.121 + case UNRECOGNIZED_PRAGMA: 1.122 + return "unrecognized pragma"; 1.123 + // Warnings end. 1.124 + default: 1.125 + assert(false); 1.126 + return ""; 1.127 + } 1.128 +} 1.129 + 1.130 +} // namespace pp