////////////////////////////////////////////////////////////////////////////// // Project: Ob51 // License: Apache License, Version 2.0; for details see LICENSE file // Copyright: see NOTICE file // // Last file commit: $Revision: 143 $ Made by: $Author: avek $ ////////////////////////////////////////////////////////////////////////////// using System; using System.Collections.Generic; using System.Text; namespace Ob51.Compiler { /// /// Represents an error or warning encountered by some module of Ob51 compiler. /// public class Issue { /// /// Codes for importance of this . /// public enum Severities { /// /// Fatal error. The compiler can't proceed and must stop /// immediately. /// FatalError, /// /// Error. The compiler may not produce output, but will check /// for more errors. /// Error, /// /// Warning. The compiler will produce output program, but it can /// behave unexpectedly in some way. /// Warning, /// /// Note. The compiler will produce a normal program. /// Note }; /// /// An exception class thrown when parser has no /// to record exceptions in. /// public class UnableToRecordIssueException : ApplicationException { /// /// that caused this exception. /// public readonly Issue IssueNotRecorded; /// /// Constructor for exception. /// /// that caused exception public UnableToRecordIssueException(Issue issue): base() { IssueNotRecorded = issue; } } /// /// The default value that specifies unknown /// internal error that happened for unrecognizable reason. /// public const uint UnknownInternalError = 100; /// /// The default value that describes /// to the user. /// public const string UnknownInternalErrorMessage = "internal compiler error"; /// /// Creates an error object with specified file location and extra info. /// public Issue(Severities severity, uint code, string message, string fileName, uint line, uint column, object extraInfo): this(severity, code, message, fileName, line, column) { this.ExtraInfo = extraInfo; } /// /// Creates an error object with specified file name and position. /// public Issue(Severities severity, uint Code, string message, string fileName, uint line, uint column) { this.Severity = severity; this.Code = Code; this.Message = message; this.FileName = fileName; this.Line = line; this.Column = column; } /// /// Creates an error object with file location as in /// . /// public Issue(Severities severity, uint code, string message, InternalTree.ProgramNode src): this(severity, code, message, src.SourceFileName, src.SourceLineNumber, src.SourceColumnNumber, src) { } /// /// Creates an error object with unspecified file name and position. /// public Issue(Severities severity, uint code, string message): this(severity, code, message, string.Empty, uint.MaxValue, uint.MaxValue) { } /// /// Default constructor for class. Creates an instance /// of "internal compiler error". /// public Issue(): this(Severities.FatalError, UnknownInternalError, UnknownInternalErrorMessage) { } /// /// Importance of this . /// public readonly Severities Severity; /// /// A value that determines exact kind of this . /// public readonly uint Code; /// /// Error or warning description in human-readable form. /// public readonly string Message; /// /// File in which the error occured. /// public readonly string FileName; /// /// Line in which the error occured. /// public readonly uint Line; /// /// Column in which the error occured. /// public readonly uint Column; /// /// Extra information field (its content depends on ). /// public readonly object ExtraInfo = null; } }