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: #include "DiagnosticsBase.h" michael@0: michael@0: #include michael@0: michael@0: namespace pp michael@0: { michael@0: michael@0: Diagnostics::~Diagnostics() michael@0: { michael@0: } michael@0: michael@0: void Diagnostics::report(ID id, michael@0: const SourceLocation& loc, michael@0: const std::string& text) michael@0: { michael@0: // TODO(alokp): Keep a count of errors and warnings. michael@0: print(id, loc, text); michael@0: } michael@0: michael@0: Diagnostics::Severity Diagnostics::severity(ID id) michael@0: { michael@0: if ((id > ERROR_BEGIN) && (id < ERROR_END)) michael@0: return ERROR; michael@0: michael@0: if ((id > WARNING_BEGIN) && (id < WARNING_END)) michael@0: return WARNING; michael@0: michael@0: assert(false); michael@0: return ERROR; michael@0: } michael@0: michael@0: std::string Diagnostics::message(ID id) michael@0: { michael@0: switch (id) michael@0: { michael@0: // Errors begin. michael@0: case INTERNAL_ERROR: michael@0: return "internal error"; michael@0: case OUT_OF_MEMORY: michael@0: return "out of memory"; michael@0: case INVALID_CHARACTER: michael@0: return "invalid character"; michael@0: case INVALID_NUMBER: michael@0: return "invalid number"; michael@0: case INTEGER_OVERFLOW: michael@0: return "integer overflow"; michael@0: case FLOAT_OVERFLOW: michael@0: return "float overflow"; michael@0: case TOKEN_TOO_LONG: michael@0: return "token too long"; michael@0: case INVALID_EXPRESSION: michael@0: return "invalid expression"; michael@0: case DIVISION_BY_ZERO: michael@0: return "division by zero"; michael@0: case EOF_IN_COMMENT: michael@0: return "unexpected end of file found in comment"; michael@0: case UNEXPECTED_TOKEN: michael@0: return "unexpected token"; michael@0: case DIRECTIVE_INVALID_NAME: michael@0: return "invalid directive name"; michael@0: case MACRO_NAME_RESERVED: michael@0: return "macro name is reserved"; michael@0: case MACRO_REDEFINED: michael@0: return "macro redefined"; michael@0: case MACRO_PREDEFINED_REDEFINED: michael@0: return "predefined macro redefined"; michael@0: case MACRO_PREDEFINED_UNDEFINED: michael@0: return "predefined macro undefined"; michael@0: case MACRO_UNTERMINATED_INVOCATION: michael@0: return "unterminated macro invocation"; michael@0: case MACRO_TOO_FEW_ARGS: michael@0: return "Not enough arguments for macro"; michael@0: case MACRO_TOO_MANY_ARGS: michael@0: return "Too many arguments for macro"; michael@0: case CONDITIONAL_ENDIF_WITHOUT_IF: michael@0: return "unexpected #endif found without a matching #if"; michael@0: case CONDITIONAL_ELSE_WITHOUT_IF: michael@0: return "unexpected #else found without a matching #if"; michael@0: case CONDITIONAL_ELSE_AFTER_ELSE: michael@0: return "unexpected #else found after another #else"; michael@0: case CONDITIONAL_ELIF_WITHOUT_IF: michael@0: return "unexpected #elif found without a matching #if"; michael@0: case CONDITIONAL_ELIF_AFTER_ELSE: michael@0: return "unexpected #elif found after #else"; michael@0: case CONDITIONAL_UNTERMINATED: michael@0: return "unexpected end of file found in conditional block"; michael@0: case INVALID_EXTENSION_NAME: michael@0: return "invalid extension name"; michael@0: case INVALID_EXTENSION_BEHAVIOR: michael@0: return "invalid extension behavior"; michael@0: case INVALID_EXTENSION_DIRECTIVE: michael@0: return "invalid extension directive"; michael@0: case INVALID_VERSION_NUMBER: michael@0: return "invalid version number"; michael@0: case INVALID_VERSION_DIRECTIVE: michael@0: return "invalid version directive"; michael@0: case VERSION_NOT_FIRST_STATEMENT: michael@0: return "#version directive must occur before anything else, " michael@0: "except for comments and white space"; michael@0: case INVALID_LINE_NUMBER: michael@0: return "invalid line number"; michael@0: case INVALID_FILE_NUMBER: michael@0: return "invalid file number"; michael@0: case INVALID_LINE_DIRECTIVE: michael@0: return "invalid line directive"; michael@0: // Errors end. michael@0: // Warnings begin. michael@0: case EOF_IN_DIRECTIVE: michael@0: return "unexpected end of file found in directive"; michael@0: case CONDITIONAL_UNEXPECTED_TOKEN: michael@0: return "unexpected token after conditional expression"; michael@0: case UNRECOGNIZED_PRAGMA: michael@0: return "unrecognized pragma"; michael@0: // Warnings end. michael@0: default: michael@0: assert(false); michael@0: return ""; michael@0: } michael@0: } michael@0: michael@0: } // namespace pp