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::prelude::*;

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

Re-exports§

Modules§

  • A collection of useful items to make it easier to work with koto

Structs§

  • An immutably borrowed reference to a value borrowed from a KCell
  • A mutably borrowed reference to a value borrowed from a KCell
  • An error thrown by the Koto runtime
  • The main interface for the Koto language.
  • Settings used to control the behaviour of the Koto runtime
  • An immutable pointer to a value in allocated memory

Type Aliases§

  • A mutable pointer to a value in allocated memory
  • The Result type used by the Koto Runtime