LRDE Tiger Compiler  1.34a $Id: 7fef12e1f5fa43449d667a0eec1d837c40fc1202 $
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
misc::error Class Reference

Handle errors in the whole project. More...

#include <error.hh>

Collaboration diagram for misc::error:

Public Member Functions

 error ()
 error (const error &e)
 ~error ()
erroroperator= (const error &e)
 Copy an error.
Member manipulators.
void exit () const
 Throw an exception to exit.
void exit_on_error () const
 If the error status is set, throw an exception to exit.
void ice (const char *file, int line) const
 Throw an Internal Compiler Error.
void ice_on_error (const char *file, int line) const
void clear ()
 Reset to no error.
Accessors.
 operator bool () const
 True if an error is recorded.
error_type status_get () const
 Get the current status.
const std::ostringstream & stream_get () const
 Get the stream associated with the class.

Private Attributes

error_type status_
 The current exit status.
std::ostringstream stream_
 The current error message.

Filling the error handler.

enum  error_type {
  success = 0, failure = 1, scan = 2, parse = 3,
  bind = 4, type = 5
}
 With what exit status should we end? More...
typedef void(error::* member_manip_type )()
 Member manipulator signature.
typedef void(error::* const_member_manip_type )() const
 Const member manipulator signature.
template<typename T >
erroroperator<< (const T &t)
 General method: put the parameter in stream_.
erroroperator<< (error_type e)
 Set the status if e is lower than the current status.
erroroperator<< (std::ostream &(*f)(std::ostream &))
 Accept std::endl etc.
erroroperator<< (const error &rhs)
 Import errors.
erroroperator<< (member_manip_type f)
 Hook for member manipulators.
erroroperator<< (const_member_manip_type f)
 Hooks for const member manipulators.

Detailed Description

Handle errors in the whole project.

Each task has an error status depending on its exit code described in the enum below.

Several versions of operator<< are used to fill the handler.

A global variable is defined to centralize all the error uses.

Member Typedef Documentation

typedef void(error::* misc::error::const_member_manip_type)() const

Const member manipulator signature.

typedef void(error::* misc::error::member_manip_type)()

Member manipulator signature.

Member Enumeration Documentation

With what exit status should we end?

Enumerator:
success 

Job successfully done.

failure 

Some unspecified error happened.

scan 

Lexical error.

parse 

Syntactic error.

bind 

Binding error: undefined name.

type 

Type checking error.

Constructor & Destructor Documentation

misc::error::error ( )
misc::error::error ( const error e)
misc::error::~error ( )

Member Function Documentation

void misc::error::clear ( )

Reset to no error.

References status_, stream_, and success.

void misc::error::exit ( ) const
void misc::error::exit_on_error ( ) const
void misc::error::ice ( const char *  file,
int  line 
) const

Throw an Internal Compiler Error.

References __Terminate(), and stream_.

Referenced by ice_on_error().

void misc::error::ice_on_error ( const char *  file,
int  line 
) const

If the error status is set, consider that an Internal Compiler Error has happened and abort.

References ice(), and status_.

misc::error::operator bool ( ) const

True if an error is recorded.

template<class T >
error & misc::error::operator<< ( const T &  t)

General method: put the parameter in stream_.

References stream_.

error & misc::error::operator<< ( error_type  e)

Set the status if e is lower than the current status.

References status_.

error & misc::error::operator<< ( std::ostream &(*)(std::ostream &)  f)

Accept std::endl etc.

References stream_.

error & misc::error::operator<< ( const error rhs)

Import errors.

References status_get(), and stream_get().

error & misc::error::operator<< ( member_manip_type  f)
inline

Hook for member manipulators.

error & misc::error::operator<< ( const_member_manip_type  f)
inline

Hooks for const member manipulators.

error & misc::error::operator= ( const error e)

Copy an error.

References status_, status_get(), stream_, and stream_get().

error::error_type misc::error::status_get ( ) const

Get the current status.

References status_.

Referenced by operator<<(), and operator=().

const std::ostringstream & misc::error::stream_get ( ) const

Get the stream associated with the class.

References stream_.

Referenced by operator<<(), misc::operator<<(), and operator=().

Member Data Documentation

error_type misc::error::status_
private

The current exit status.

Referenced by clear(), exit_on_error(), ice_on_error(), operator<<(), operator=(), and status_get().

std::ostringstream misc::error::stream_
private

The current error message.

Referenced by clear(), ice(), operator<<(), operator=(), and stream_get().


The documentation for this class was generated from the following files: