GSC Interpreter
A Turing-complete interpreter developed for a compiler course
Loading...
Searching...
No Matches
RuntimeError Class Reference

Represents a runtime error in the GSC interpreter. More...

#include <runtimeError.hpp>

Inheritance diagram for RuntimeError:
Collaboration diagram for RuntimeError:

Public Member Functions

 RuntimeError (std::shared_ptr< Token > token, std::string_view message)
 Constructs a RuntimeError with a token and a message.
 
std::shared_ptr< TokengetToken () const
 
std::string getMessage () const
 

Private Attributes

std::shared_ptr< Tokentoken
 

Detailed Description

Represents a runtime error in the GSC interpreter.

Note
This class extends std::runtime_error to provide additional context about the error, including the token that caused it and a message describing the error.

Definition at line 14 of file runtimeError.hpp.

Constructor & Destructor Documentation

◆ RuntimeError()

RuntimeError::RuntimeError ( std::shared_ptr< Token token,
std::string_view  message 
)
inline

Constructs a RuntimeError with a token and a message.

Parameters
tokenA shared pointer to the Token that caused the error.
messageA string view containing the error message.

Definition at line 24 of file runtimeError.hpp.

25 : std::runtime_error(message.data()), token(token) {}
std::shared_ptr< Token > token

Member Function Documentation

◆ getMessage()

std::string RuntimeError::getMessage ( ) const
inline

Definition at line 29 of file runtimeError.hpp.

29{ return what(); }

◆ getToken()

std::shared_ptr< Token > RuntimeError::getToken ( ) const
inline

Definition at line 27 of file runtimeError.hpp.

27{ return token; }

Member Data Documentation

◆ token

std::shared_ptr<Token> RuntimeError::token
private

Definition at line 16 of file runtimeError.hpp.


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