Module teko::interpret [] [src]

Evaluation and library functions.

extern crate teko;
extern crate num_traits;
use num_traits::cast::ToPrimitive;
fn main() {
    let program = teko::parse::parse_string("(+ 1 2 4) (+ 1 2)").ok().unwrap();
    let env = teko::interpret::interpret(program);
    match env.result.1 {
        teko::data_structures::Coredata::Integer(ref value) => {
            assert_eq![value.to_i32().unwrap(), 3];
        }
        _ => {
            panic!["Expected Integer but got a different data type"];
        }
    }
}

Functions

eval

Evaluates a program with a given environment.

initialize_environment_with_standard_library

Initializes the environment with the standard library.

interpret

Sets up a standard environment and evaluate the program.