summaryrefslogtreecommitdiff
path: root/src/nibble/mod.rs
blob: 14791fd788bbbe0cce23eb4fb2d80e816e54f423 (plain)
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
pub mod convert;
pub mod cst;
// impl File {
//     /// Returns function list and the goal. The function list consists of an
//     /// [`Ident`], the converted [`ast::Expression`] and the number of arguments.
//     pub fn convert(self) -> (Vec<(Ident, ast::Expression, usize)>, ast::Expression) {
//         let mut context = Context::new();
//         let map = self
//             .lets
//             .into_iter()
//             .map(|stmt| {
//                 let count = stmt.args.as_ref().map(ArgList::len).unwrap_or_default();
//                 context.set_variables(
//                     stmt.args
//                         .into_iter()
//                         .flat_map(|args| args.into_iter().map(|arg| arg.to_string())),
//                 );
//                 (stmt.name, stmt.expr.convert(&mut context), count)
//             })
//             .collect();
//         let goal = self.goal.expr.convert(&mut context);
//         (map, goal)
//     }
// }

// #[cfg(test)]
// mod tests {
//     use super::{Epsilon, Ident, Literal};
//     use syn::parse_str;

//     #[test]
//     fn parse_epsilon() {
//         assert!(parse_str::<Epsilon>("_").is_ok());
//     }

//     #[test]
//     fn parse_ident() {
//         assert_eq!(parse_str::<Ident>("x").unwrap().to_string(), "x");
//         assert_eq!(parse_str::<Ident>("x_yz").unwrap().to_string(), "x_yz");
//         assert_eq!(parse_str::<Ident>("a123").unwrap().to_string(), "a123");
//         assert_eq!(parse_str::<Ident>("𝒢𝒢").unwrap().to_string(), "𝒢𝒢");
//         assert!(parse_str::<Ident>("1").is_err());
//         assert!(parse_str::<Ident>("_").is_err());
//     }

//     #[test]
//     fn parse_literal() {
//         assert_eq!(parse_str::<Literal>(r#""hello""#).unwrap().value(), "hello")
//     }
// }