Nearly CC
An educational compiler skeleton
Public Member Functions | Static Public Member Functions | List of all members
SyntaxError Class Reference

Exception type for lexical or syntax errors. More...

#include "exceptions.h"

Inheritance diagram for SyntaxError:
Inheritance graph
[legend]
Collaboration diagram for SyntaxError:
Collaboration graph
[legend]

Public Member Functions

 SyntaxError (const Location &loc, const std::string &desc)
 Constructor. More...
 
 SyntaxError (const SyntaxError &other)
 Copy constructor. More...
 
bool has_location () const
 Check whether this exception has a valud source Location. More...
 
const Locationget_loc () const
 Get the source Location. More...
 

Static Public Member Functions

static void raise (const Location &loc, const char *fmt,...) EX_PRINTF_FORMAT
 Throw a SyntaxError exception. More...
 

Detailed Description

Exception type for lexical or syntax errors.

Constructor & Destructor Documentation

◆ SyntaxError() [1/2]

SyntaxError::SyntaxError ( const Location loc,
const std::string &  desc 
)

Constructor.

Parameters
locthe source Location
descdescription of the error

◆ SyntaxError() [2/2]

SyntaxError::SyntaxError ( const SyntaxError other)

Copy constructor.

Parameters
otherthe SyntaxError object to copy from

Member Function Documentation

◆ get_loc()

const Location & BaseException::get_loc ( ) const
inherited

Get the source Location.

Returns
the source Location

◆ has_location()

bool BaseException::has_location ( ) const
inlineinherited

Check whether this exception has a valud source Location.

Returns
true if this exception has a valid source Location, false otherwise

◆ raise()

void SyntaxError::raise ( const Location loc,
const char *  fmt,
  ... 
)
static

Throw a SyntaxError exception.

The description is generated from printf-style formatting.

Parameters
fmtthe format string
...argument values (corresponding to conversions in the format string)

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