template-project-cpp
|
The tpcpp interpreter, which is a simple calculator. More...
#include <Interpreter.hpp>
Public Member Functions | |
void | run () |
Start the interpreter REPL loop. | |
Object | evaluate (const std::string &expr) |
Evaluate a given string. | |
void | error (const std::string &message) |
Indicate a parsing-time error to the intepreter. | |
void | runtimeError (const RuntimeError &error) |
Indicate a run-time error to the intepreter. | |
void | setVariable (const std::string &name, const Object &value) |
Set a global variable. | |
Object | getVariable (const std::string &name) |
Get a global variable. | |
Private Member Functions | |
void | registerFunctions () |
Register native functions to the tpcpp interpreter. | |
The tpcpp interpreter, which is a simple calculator.
Definition at line 12 of file Interpreter.hpp.
void tpcpp::Interpreter::error | ( | const std::string & | message | ) |
Indicate a parsing-time error to the intepreter.
[in] | message | The error message. |
Definition at line 85 of file Interpreter.cpp.
Object tpcpp::Interpreter::evaluate | ( | const std::string & | source | ) |
Evaluate a given string.
[in] | source | The source code to evaluate. |
tpcpp::Object
. Definition at line 57 of file Interpreter.cpp.
Object tpcpp::Interpreter::getVariable | ( | const std::string & | name | ) |
Get a global variable.
[in] | name | The name of the variable. |
Definition at line 110 of file Interpreter.cpp.
|
private |
Register native functions to the tpcpp interpreter.
sin
cos
abs
max
min
Definition at line 128 of file Interpreter.cpp.
void tpcpp::Interpreter::runtimeError | ( | const RuntimeError & | error | ) |
Indicate a run-time error to the intepreter.
[in] | error | A tpcpp::RuntimeError instance. |
Definition at line 93 of file Interpreter.cpp.
void tpcpp::Interpreter::setVariable | ( | const std::string & | name, |
const Object & | value ) |
Set a global variable.
[in] | name | The name of the variable. |
[in] | value | The value of the variable. |
Definition at line 102 of file Interpreter.cpp.