Plot Script
Public Member Functions | List of all members
Interpreter Class Reference

Class to parse and evaluate an expression (program) More...

#include <interpreter.hpp>

Public Member Functions

bool parseStream (std::istream &expression) noexcept
 
Expression evaluate ()
 

Detailed Description

Class to parse and evaluate an expression (program)

Interpreter has an Environment, which starts at a default. The parse method builds an internal AST. The eval method updates Environment and returns last result.

Member Function Documentation

◆ evaluate()

Expression Interpreter::evaluate ( )

Evaluate the Expression by walking the tree, returning the result.

Returns
the Expression resulting from the evaluation in the current environment
Exceptions
SemanticErrorwhen a semantic error is encountered

◆ parseStream()

bool Interpreter::parseStream ( std::istream &  expression)
noexcept

Parse into an internal Expression from a stream

Parameters
expressionthe raw text stream repreenting the candidate expression
Returns
true on successful parsing

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