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 buffer::CodeBuffer; |
pub use buffer::More; |
pub use buffer::MoreResult; |
pub use bytecode::Code; |
pub use bytes::Bytes; |
pub use completion::complete_name; |
pub use compile::CompileError; |
pub use encode::DecodeError; |
pub use encode::EncodeError; |
pub use error::Error; |
pub use exec::Context; |
pub use exec::ExecError; |
pub use exec::panic; |
pub use exec::panic_none; |
pub use function::Arity; |
pub use interpreter::Builder; |
pub use interpreter::Interpreter; |
pub use integer::Integer; |
pub use integer::Ratio; |
pub use io::File; |
pub use io::GlobalIo; |
pub use io::IoError; |
pub use io::SharedWrite; |
pub use module::BuiltinModuleLoader; |
pub use module::FileModuleLoader; |
pub use module::Module; |
pub use module::ModuleBuilder; |
pub use module::ModuleLoader; |
pub use name::Name; |
pub use name::NameStore; |
pub use parser::ParseError; |
pub use parser::ParseErrorKind; |
pub use restrict::RestrictConfig; |
pub use restrict::RestrictError; |
pub use run::run_code; |
pub use scope::GlobalScope; |
pub use scope::Scope; |
pub use trace::clear_traceback; |
pub use trace::get_traceback; |
pub use trace::set_traceback; |
pub use trace::take_traceback; |
pub use trace::Trace; |
pub use value::ForeignValue; |
pub use value::FromValue; |
pub use value::FromValueRef; |
pub use value::Value; |
Modules
args |
Provides a helper macro for extracting arguments from Ketos values. |
buffer |
Provides a code buffer to help with implementing an interactive REPL |
bytecode |
Implements encoding and decoding of bytecode instruction format. |
bytes |
Implements a reference-counted byte string supporting efficient subslicing. |
compile |
Compiles expressions into bytecode objects. |
completion |
Performs name-based text completion using a |
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
ketos_args |
Parses a set of arguments from a |
ketos_fn |
Creates a foreign function that implicitly converts input arguments
into Rust values and converts its result into a |