Crate koto

source · []
Expand description

Koto

Pulls together the compiler and runtime for the Koto programming language.

Programs can be compiled and executed with the Koto struct.

Example

use koto::{Koto, runtime::Value};

let mut koto = Koto::default();
match koto.compile("1 + 2") {
    Ok(_) => match koto.run() {
        Ok(result) => match result {
            Value::Number(n) => println!("{n}"), // 3.0
            other => panic!("Unexpected result: {}", other),
        },
        Err(runtime_error) => {
            panic!("Runtime error: {runtime_error}");
        }
    },
    Err(compiler_error) => {
        panic!("Compiler error: {compiler_error}");
    }
}

Re-exports

pub use koto_bytecode as bytecode;
pub use koto_parser as parser;
pub use koto_runtime as runtime;

Structs

The main interface for the Koto language.

Settings used to control the behaviour of the Koto runtime

Enums

Type Definitions