gfy-cpp
Loading...
Searching...
No Matches
Interpreter Class Reference

#include <interpreter.hpp>

Public Member Functions

 Interpreter (const char *source)
 Constructor.
 
 Interpreter (const string &source)
 Constructor.
 
void run ()
 Run the interpreter.
 

Private Member Functions

void import_module (const string &module_path)
 Import a module.
 
void handle_keyword (const string &keyword)
 Handle a keyword.
 

Private Attributes

size_t curr_tk = 0
 
vector< Tokentokens
 
Memory memory
 

Constructor & Destructor Documentation

◆ Interpreter() [1/2]

Interpreter::Interpreter ( const char * source)

Constructor.

Constructor for the interpreter.

Parameters
sourceSource code to interpret

◆ Interpreter() [2/2]

Interpreter::Interpreter ( const string & source)
inline

Constructor.

Constructor for the interpreter.

Parameters
sourceSource code to interpret

Member Function Documentation

◆ handle_keyword()

void Interpreter::handle_keyword ( const string & keyword)
private

Handle a keyword.

Handle a keyword. The function is called when the interpreter finds a keyword in the source code. It checks the keyword and executes the corresponding action.

Parameters
keywordKeyword to handle

◆ import_module()

void Interpreter::import_module ( const string & module_path)
private

Import a module.

Import a module into the current source code. The function reads the module file, generates the tokens, checks for errors and inserts the token list.

Parameters
module_pathPath to the module file

◆ run()

void Interpreter::run ( )

Run the interpreter.

Run the interpreter. It takes the tokens generated by the lexer and interprets them. In case of an error, the function throws an exception containing the error message.

Field Documentation

◆ curr_tk

size_t Interpreter::curr_tk = 0
private

◆ memory

Memory Interpreter::memory
private

◆ tokens

vector<Token> Interpreter::tokens
private

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