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
/// Evaluate one or more S-Expressions, in the base context or your own custom one.
///
/// # Examples
/// ```
/// use parsley::prelude::*;
/// assert!(eval!(sexp![SExp::sym("list"), "potato", true, 5]).is_ok());
/// assert!(eval!(sexp!["potato", true, 5]).is_err());
/// ```
/// ```
/// use parsley::prelude::*;
///
/// let evaluated = eval!(
/// sexp![
/// SExp::sym("define"),
/// sexp![SExp::sym("square"), SExp::sym("x")],
/// sexp![SExp::sym("*"), SExp::sym("x"), SExp::sym("x")]
/// ],
/// sexp![SExp::sym("square"), 12]
/// );
///
/// assert!(evaluated.is_ok());
/// assert_eq!(evaluated.unwrap(), SExp::from(144));
/// ```
/// ```
/// use parsley::prelude::*;
/// let mut ctx = Context::base();
///
/// eval!(
/// ctx;
/// sexp![
/// SExp::sym("define"),
/// sexp![SExp::sym("potato"), SExp::sym("x"), SExp::sym("y")],
/// SExp::sym("y")
/// ]
/// );
/// let evaluated = eval!(ctx; sexp![SExp::sym("potato"), true, 5]);
///
/// assert!(evaluated.is_ok());
/// assert_eq!(evaluated.unwrap(), SExp::from(5));
/// ```