unlambda/lib.rs
1//! Unlambda interpreter library.
2//!
3//! Written on a whim. I had intended to write a rust unlambda binary, and maybe
4//! I'll get to that but this project does nobody any good sitting in my
5//! `~/code` folder.
6//!
7//! It's rough around the edges and the docs are almost non-existent. The
8//! important parts of the api are exposed at the top level but it's been long
9//! enough since I looked that really I just fixed obvious warts and exposed
10//! more-or-less everything. If you want to use a library to evaluate unlambda,
11//! then far be it from me to stop you from getting deep into my code's guts.
12//!
13//! # Example
14//!
15//! ```
16//! # fn main() -> Result<(), unlambda::EvalError> {
17//! use unlambda::Input;
18//! let source = "`.!`.d`.l`.r`.o`.w`. `.,`.o`.l`.l`.e`.Hi";
19//! // `unlambda::Input` is the "stdin", which can be a string,
20//! // a file, actual stdin, ... It defaults to the empty string.
21//! let input = unlambda::Input::default();
22//! // Produces an error if we fail to parse, or if the
23//! // unlambda program does some IO which itself produces an error.
24//! let output = unlambda::eval_to_string(source, input)?;
25//! assert_eq!(output, "Hello, world!");
26//! # Ok(())
27//! # }
28//! ```
29
30pub use eval::{eval_to_stdout, eval_to_string, eval_to_vec, Error as EvalError};
31pub use io::Input;
32pub use parse::{parse_from_file, parse_from_reader, parse_from_stdin, parse_from_str, ParseError};
33pub use util::P;
34
35pub mod eval;
36pub mod internals;
37pub mod io;
38pub mod parse;
39mod util;
40
41pub(crate) use eval::*;
42pub(crate) use internals::*;
43pub(crate) use io::*;
44pub(crate) use parse::*;
45pub(crate) use util::p;