//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// PLEASE DO NOT EDIT WITHOUT THE EXPLICIT CONSENT OF THE AUTHOR! \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
using System.IO;
namespace Ilog.Language.Parsing
{
/**
* This the abstract class of objects for managing and reporting
* errors. The method ReportError(Error error) must be
* provided by a concrete class deriving from this class. For common
* uses, this namespace also provides the concrete class
* DefaultErrorManager whose error reporting method amounts
* to printing the specified error on System.Console.Error
* (which is the default error stream and may be reset to another
* TextWriter if desired).
*
* @version Last modified on Sun May 29 08:35:10 2005 by hak
* @author Hassan Aït-Kaci
* @copyright © 2001 ILOG, S.A.
*
* @see DefaultErrorManager
*/
public abstract class ErrorManager
{
/**
* The error stream on which error messages are displayed.
* The default is System.Console.Error.
*/
private TextWriter errorStream = System.Console.Error;
public TextWriter ErrorStream
{
get { return errorStream; }
set { errorStream = value; }
}
/**
* This is true iff this error manager is set to report errors.
* The default is true.
*/
private bool isReportingErrors = true;
public bool IsReportingErrors
{
get { return isReportingErrors; }
set { isReportingErrors = value; }
}
/**
* Enables (resp., disables) error reporting for this error manager iff
* the specified flag is true (resp., false).
*/
public void ReportErrors (bool flag)
{
isReportingErrors = flag;
}
/**
* This is true iff this error manager is set to recover from errors.
* The default is true.
*/
private bool isRecoveringErrors = true;
public bool IsRecoveringErrors
{
get { return isRecoveringErrors; }
set { isRecoveringErrors = value; }
}
/**
* Enables (resp., disables) error recovery for this error manager iff
* the specified flag is true (resp., false).
*/
public void RecoverFromErrors (bool flag)
{
isRecoveringErrors = flag;
}
/**
* The number of errors issued by this error manager.
*/
private int errorCount = 0;
public int ErrorCount
{
get { return errorCount; }
set { errorCount = value; }
}
/**
* Increments the number of errors.
*/
public void CountError ()
{
errorCount++;
}
/**
* This is true iff this error manager has errors.
*/
public bool HasErrors
{
get { return errorCount > 0; }
}
/**
* The number of warnings issued by this error manager.
*/
private int warningCount = 0;
public int WarningCount
{
get { return warningCount; }
set { warningCount = value; }
}
/**
* Increments the number of warnings.
*/
public void CountWarning ()
{
warningCount++;
}
/**
* This is true iff this error manager has errors.
*/
public bool HasWarnings
{
get { return warningCount > 0; }
}
/**
* The number of deprecated uses issued by this error manager.
*/
private int deprecatedCount = 0;
public int DeprecatedCount
{
get { return deprecatedCount; }
set { deprecatedCount = value; }
}
/**
* Increments the number of deprecation warning.
*/
public void CountDeprecated ()
{
deprecatedCount++;
}
/**
* This is true iff this error manager has deprecated
* warnings.
*/
public bool HasDeprecateds
{
get { return deprecatedCount > 0; }
}
/**
* Reports the specified error as an error.
*/
public abstract void ReportError (Error error);
/**
* Reports the specified error as a warning.
*/
public abstract void ReportWarning (Error error);
/**
* Reports the specified error as a deprecation warning.
*/
public abstract void ReportDeprecated (Error error);
/**
* Reports a recapitulation of all errors.
*/
public abstract void TallyErrors ();
/**
* Reports a recapitulation of all warnings.
*/
public abstract void TallyWarnings ();
/**
* Reports a recapitulation of all deprecation warnings.
*/
public abstract void TallyDeprecateds ();
/**
* Resets the error manager to a fresh state.
*/
public void Reset ()
{
isReportingErrors = true;
isRecoveringErrors = true;
errorCount = 0;
warningCount = 0;
deprecatedCount = 0;
}
}
}