Lines Matching refs:Atom
32 /// We now wrap this type and a few other primitives into our Atom type.
36 pub enum Atom {
46 /// Expr::Quote(vec![Expr::Constant(Atom::Num(1)),
47 /// Expr::Constant(Atom::Num(2)),
48 /// Expr::Constant(Atom::Num(3))])
55 Constant(Atom),
99 fn parse_bool<'a>(i: &'a str) -> IResult<&'a str, Atom, VerboseError<&'a str>> {
101 map(tag("#t"), |_| Atom::Boolean(true)),
102 map(tag("#f"), |_| Atom::Boolean(false)),
112 fn parse_keyword<'a>(i: &'a str) -> IResult<&'a str, Atom, VerboseError<&'a str>> {
115 |sym_str: &str| Atom::Keyword(sym_str.to_string()),
121 fn parse_num<'a>(i: &'a str) -> IResult<&'a str, Atom, VerboseError<&'a str>> {
124 digit_str.parse::<i32>().map(Atom::Num)
127 Atom::Num(-1 * digit_str.parse::<i32>().unwrap())
134 fn parse_atom<'a>(i: &'a str) -> IResult<&'a str, Atom, VerboseError<&'a str>> {
138 map(parse_builtin, Atom::BuiltIn),
250 if let Expr::Constant(Atom::Num(n)) = e {
258 if let Expr::Constant(Atom::Boolean(b)) = e {
266 /// This has to return an Expression rather than an Atom because quoted s_expressions
296 if let Expr::Constant(Atom::BuiltIn(bi)) = reduced_head {
298 BuiltIn::Plus => Atom::Num(
306 BuiltIn::Times => Atom::Num(
314 BuiltIn::Equal => Atom::Boolean(
324 Atom::Boolean(!get_bool_from_expr(reduced_tail.first().cloned().unwrap())?)
327 BuiltIn::Minus => Atom::Num(if let Some(first_elem) = reduced_tail.first().cloned() {
339 BuiltIn::Divide => Atom::Num(if let Some(first_elem) = reduced_tail.first().cloned() {