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
macro_rules! make_error {
    ($fmt:literal, $($fmtargs:expr),*) => {
        $crate::Value::Exception(Box::new($crate::value::Exception {
            message: format!($fmt, $($fmtargs),*),
            irritants: Vec::new(),
        }))
    };
    ($fmt:literal; $($irritants:expr),*) => {
        $crate::Value::Exception(Box::new($crate::value::Exception {
            message: $fmt.into(),
            irritants: vec![$($irritants),*],
        }))
    };
    ($fmt:literal, $($fmtargs:expr),*; $($irritants:expr),*) => {
        $crate::Value::Exception(Box::new($crate::value::Exception {
            message: format!($fmt, $($fmtargs),*),
            irritants: vec![$($irritants),*],
        }))
    };
}

macro_rules! try_value {
    ($expr:expr) => {{
        let v = $expr;
        if let Value::Exception(_) = v {
            return v.into();
        } else {
            v
        }
    }};
}

macro_rules! try_result {
    ($expr:expr) => {
        match $expr {
            Ok(v) => v,
            Err(e) => return e.into(),
        }
    };
}

mod ast;
mod prim;
mod util;
mod value;
mod vm;

pub use value::{PrimOp, Value};
pub use vm::{EvalError, Vm};