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
//! Arithmetic expression evaluator.
//!
//! Start things off by creating its environment which will hold the available builtins and the last answer.
//!
//! ```
//! extern crate pupil;
//! 
//! // Creates an empty environment.
//! let empty = pupil::Env::new();
//! // Creates an environment initialized with the default builtins.
//! let env = pupil::Env::default();
//! ```
//!
//! Create an expression and bind it to its environment.
//!
//! ```
//!# extern crate pupil;
//!# let env = pupil::Env::default();
//! let mut expr = pupil::Expr::new(&env);
//! 
//! // Feed it input, note that you cannot give it partial tokens.
//! expr.feed("2 +").unwrap();
//! expr.feed("3").unwrap();
//! 
//! // Calculate the final result.
//! let result = expr.result().unwrap();
//! ```
//!
//! You can perform the expression evaluation in a single step.
//!
//! ```
//!# extern crate pupil;
//!# let mut env = pupil::Env::default();
//! let result = pupil::Expr::new(&env).eval("2 + 3").unwrap();
//! ```

extern crate libc;

pub mod env;
pub mod expr;
pub mod lexer;
pub mod op;
pub mod builtins;

pub use expr::Expr;
pub use env::Env;