Crate koto

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(chunk) => match koto.run(chunk) {
        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§

pub use koto_bytecode as bytecode;
pub use koto_parser as parser;
pub use koto_runtime as runtime;
pub use koto_runtime::derive;
pub use koto_serde as serde;

Modules§

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

Structs§

Borrow
An immutably borrowed reference to a value borrowed from a PtrMut
BorrowMut
A mutably borrowed reference to a value borrowed from a PtrMut
CompileArgs
Arguments for Koto::compile
Koto
The main interface for the Koto language.
KotoSettings
Settings used to control the behaviour of the Koto runtime
Ptr
An immutable pointer to a value in allocated memory

Enums§

Error
The different error types that can result from Koto operations
ErrorKind
The different error types that can be thrown by the Koto runtime

Type Aliases§

PtrMut
A mutable pointer to a value in allocated memory
Result
The Result type returned by Koto operations