1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
/*!
Tulisp is a Lisp interpreter that can be embedded into Rust programs. The
syntax tries to closely match that of Emacs Lisp. It was primarily designed to
be a configuration language, but it also works well as a general purpose
embedded scripting language.
One of the many benefits of using the Emacs Lisp syntax is that we can reuse its
documentation for the builtin functions and macros. And for people who are
already familiar with Emacs Lisp, there's no need to learn an extra language.
## Getting started
Tulisp requires `rustc` version 1.58 or higher.
It is very easy to get started. Here's an example:
*/
/*!
```rust
use tulisp::{TulispContext, tulisp_fn, Error};
fn main() -> Result<(), Error> {
// Create a new Tulisp execution context.
let mut ctx = TulispContext::new();
// Add a function called `add_nums` to `ctx`.
#[tulisp_fn(add_func = "ctx")]
fn add_nums(num1: i64, num2: i64) -> i64 {
num1 + num2
}
// Write a lisp program that calls `add_nums`
let program = "(add_nums 10 20)";
// Evaluate the program, and save the result.
let sum: i64 = ctx.eval_string(program)?.try_into()?;
assert_eq!(sum, 30);
Ok(())
}
```
## Builtin functions
A list of currently available builtin functions can be found [here](builtin).
*/
/*!
## Next steps
1. Values in _Tulisp_ are represented in rust as [`TulispObject`](TulispObject)s.
That struct implements methods for performing operations on Tulisp values.
1. [`TulispContext`](TulispContext) tracks the state of the interpreter and
provides methods for executing _Tulisp_ programs.
1. [`#[tulisp_fn]`](tulisp_fn) and [`#[tulisp_fn_no_eval]`](tulisp_fn_no_eval)
are flexible attribute macros for adding many different kinds of functions to
a `TulispContext` object, so that they can be called from lisp code.
*/
mod eval;
mod macros;
mod parse;
pub use tulisp_proc_macros::{tulisp_add_func, tulisp_add_macro, tulisp_fn, tulisp_fn_no_eval};
pub mod builtin;
mod cons;
pub use cons::{BaseIter, Iter};
mod context;
pub use context::TulispContext;
mod error;
pub use error::{Error, ErrorKind};
pub mod lists;
mod value;
pub use value::TulispValue;
mod object;
pub use object::TulispObject;