Crate ketos [−] [src]
Ketos is a Lisp dialect functional programming language, designed to be a scripting and extension language for Rust programs.
use ketos::{Interpreter, FromValueRef}; // Create an interpreter. let interp = Interpreter::new(); // Define a function. interp.run_code(r#" (define (foo a) (* a 2)) "#, None).unwrap(); // Call the function. let result = interp.call("foo", vec![123.into()]).unwrap(); // Get a Rust value back. let n = i32::from_value_ref(&result).unwrap(); assert_eq!(n, 246);
See examples/ for more examples on interacting with the Ketos interpreter.
Reexports
pub use bytecode::Code; |
pub use compile::CompileError; |
pub use encode::{DecodeError, EncodeError}; |
pub use error::Error; |
pub use exec::{Context, ExecError, panic, panic_none}; |
pub use function::Arity; |
pub use interpreter::{Builder, Interpreter}; |
pub use integer::{Integer, Ratio}; |
pub use io::{File, GlobalIo, IoError, SharedWrite}; |
pub use module::{BuiltinModuleLoader, FileModuleLoader, Module, ModuleBuilder, ModuleLoader}; |
pub use name::{Name, NameStore}; |
pub use parser::{ParseError, ParseErrorKind}; |
pub use restrict::{RestrictConfig, RestrictError}; |
pub use run::run_code; |
pub use scope::{GlobalScope, Scope}; |
pub use trace::{clear_traceback, get_traceback, set_traceback, take_traceback, Trace}; |
pub use value::{ForeignValue, FromValue, FromValueRef, Value}; |
Modules
| bytecode |
Implements encoding and decoding of bytecode instruction format. |
| compile |
Compiles expressions into bytecode objects. |
| encode |
Implements encoding and decoding of compiled bytecode file format. |
| error |
Contains consolidated |
| exec |
Implements a virtual machine which interprets bytecode functions. |
| function |
Contains implementations of core system functions. |
| integer |
Arbitrary precision integer and ratio types. |
| interpreter |
Provides a context in which to compile and execute code. |
| io |
Creates an abstraction layer to I/O operations |
| lexer |
Produces tokens from an input stream. |
| module |
Implements loading named values from code modules. |
| name |
Implements name interning and containers using names as keys. |
| parser |
Parses a series of |
| pretty |
Facilities for pretty-printing |
| rc_vec |
Implements a reference-counted |
| restrict |
Configuration of runtime execution restrictions |
| run |
Provides a facility for running code within an existing scope. |
| scope |
Contains values associated with names in a given execution context. |
| string_fmt |
Implements string formatting syntax. |
| trace |
Provides facilities for expressing and storing tracebacks. |
| value |
Represents any possible value type. |
Macros
| foreign_type_conversions! |
Generates conversion trait implementations for the given type. |
| ketos_fn! |
Creates a foreign function that implicitly converts input arguments
into Rust values and converts its result into a |