lisp.rs 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  1. #![allow(non_snake_case)]
  2. use crate::types::LispCircuit;
  3. use bellman::groth16::PreparedVerifyingKey;
  4. use sapvi::{BlsStringConversion, Decodable, Encodable, ZKContract, ZKProof};
  5. use simplelog::*;
  6. use bellman::groth16;
  7. use bls12_381::Bls12;
  8. use fnv::FnvHashMap;
  9. use itertools::Itertools;
  10. use rand::rngs::OsRng;
  11. use std::fs;
  12. use std::fs::File;
  13. use std::rc::Rc;
  14. use std::time::Instant;
  15. use types::EnforceAllocation;
  16. #[macro_use]
  17. extern crate clap;
  18. #[macro_use]
  19. extern crate lazy_static;
  20. extern crate fnv;
  21. extern crate itertools;
  22. extern crate regex;
  23. #[macro_use]
  24. mod types;
  25. use crate::types::MalErr::{ErrMalVal, ErrString};
  26. use crate::types::MalVal::{Bool, Enforce, Func, Hash, List, MalFunc, Nil, Str, Sym, Vector};
  27. use crate::types::VerifyKeyParams;
  28. use crate::types::{error, format_error, MalArgs, MalErr, MalRet, MalVal};
  29. mod env;
  30. mod printer;
  31. mod reader;
  32. use crate::env::{env_bind, env_find, env_get, env_new, env_set, env_sets, Env};
  33. #[macro_use]
  34. mod core;
  35. pub const ZK_CIRCUIT_ENV_KEY: &str = "ZKC";
  36. // read
  37. fn read(str: &str) -> MalRet {
  38. reader::read_str(str.to_string())
  39. }
  40. // eval
  41. fn qq_iter(elts: &MalArgs) -> MalVal {
  42. let mut acc = list![];
  43. for elt in elts.iter().rev() {
  44. if let List(v, _) = elt {
  45. if v.len() == 2 {
  46. if let Sym(ref s) = v[0] {
  47. if s == "splice-unquote" {
  48. acc = list![Sym("concat".to_string()), v[1].clone(), acc];
  49. continue;
  50. }
  51. }
  52. }
  53. }
  54. acc = list![Sym("cons".to_string()), quasiquote(&elt), acc];
  55. }
  56. return acc;
  57. }
  58. fn quasiquote(ast: &MalVal) -> MalVal {
  59. match ast {
  60. List(v, _) => {
  61. if v.len() == 2 {
  62. if let Sym(ref s) = v[0] {
  63. if s == "unquote" {
  64. return v[1].clone();
  65. }
  66. }
  67. }
  68. return qq_iter(&v);
  69. }
  70. Vector(v, _) => return list![Sym("vec".to_string()), qq_iter(&v)],
  71. Hash(_, _) | Sym(_) => return list![Sym("quote".to_string()), ast.clone()],
  72. _ => ast.clone(),
  73. }
  74. }
  75. fn is_macro_call(ast: &MalVal, env: &Env) -> Option<(MalVal, MalArgs)> {
  76. match ast {
  77. List(v, _) => match v[0] {
  78. Sym(ref s) => match env_find(env, s) {
  79. Some(e) => match env_get(&e, &v[0]) {
  80. Ok(f @ MalFunc { is_macro: true, .. }) => Some((f, v[1..].to_vec())),
  81. _ => None,
  82. },
  83. _ => None,
  84. },
  85. _ => None,
  86. },
  87. _ => None,
  88. }
  89. }
  90. fn macroexpand(mut ast: MalVal, env: &Env) -> (bool, MalRet) {
  91. let mut was_expanded = false;
  92. while let Some((mf, args)) = is_macro_call(&ast, env) {
  93. //println!("macroexpand 1: {:?}", ast);
  94. ast = match mf.apply(args) {
  95. Err(e) => return (false, Err(e)),
  96. Ok(a) => a,
  97. };
  98. //println!("macroexpand 2: {:?}", ast);
  99. was_expanded = true;
  100. }
  101. (was_expanded, Ok(ast))
  102. }
  103. fn eval_ast(ast: &MalVal, env: &Env) -> MalRet {
  104. match ast {
  105. Sym(_) => Ok(env_get(&env, &ast)?),
  106. List(v, _) => {
  107. let mut lst: MalArgs = vec![];
  108. for a in v.iter() {
  109. lst.push(eval(a.clone(), env.clone())?)
  110. }
  111. Ok(list!(lst))
  112. }
  113. Vector(v, _) => {
  114. let mut lst: MalArgs = vec![];
  115. for a in v.iter() {
  116. lst.push(eval(a.clone(), env.clone())?)
  117. }
  118. Ok(vector!(lst))
  119. }
  120. Hash(hm, _) => {
  121. let mut new_hm: FnvHashMap<String, MalVal> = FnvHashMap::default();
  122. for (k, v) in hm.iter() {
  123. new_hm.insert(k.to_string(), eval(v.clone(), env.clone())?);
  124. }
  125. Ok(Hash(Rc::new(new_hm), Rc::new(Nil)))
  126. }
  127. _ => Ok(ast.clone()),
  128. }
  129. }
  130. fn eval(mut ast: MalVal, mut env: Env) -> MalRet {
  131. let ret: MalRet;
  132. 'tco: loop {
  133. ret = match ast.clone() {
  134. List(l, _) => {
  135. if l.len() == 0 {
  136. return Ok(ast);
  137. }
  138. match macroexpand(ast.clone(), &env) {
  139. (true, Ok(new_ast)) => {
  140. ast = new_ast;
  141. continue 'tco;
  142. }
  143. (_, Err(e)) => return Err(e),
  144. _ => (),
  145. }
  146. if l.len() == 0 {
  147. return Ok(ast);
  148. }
  149. let a0 = &l[0];
  150. match a0 {
  151. Sym(ref a0sym) if a0sym == "def!" => {
  152. env_set(&env, l[1].clone(), eval(l[2].clone(), env.clone())?)
  153. }
  154. Sym(ref a0sym) if a0sym == "let*" => {
  155. env = env_new(Some(env.clone()));
  156. let (a1, a2) = (l[1].clone(), l[2].clone());
  157. match a1 {
  158. List(ref binds, _) | Vector(ref binds, _) => {
  159. for (b, e) in binds.iter().tuples() {
  160. match b {
  161. Sym(_) => {
  162. let _ = env_set(
  163. &env,
  164. b.clone(),
  165. eval(e.clone(), env.clone())?,
  166. );
  167. }
  168. _ => {
  169. return error("let* with non-Sym binding");
  170. }
  171. }
  172. }
  173. }
  174. _ => {
  175. return error("let* with non-List bindings");
  176. }
  177. };
  178. ast = a2;
  179. continue 'tco;
  180. }
  181. Sym(ref a0sym) if a0sym == "quote" => Ok(l[1].clone()),
  182. Sym(ref a0sym) if a0sym == "quasiquoteexpand" => Ok(quasiquote(&l[1])),
  183. Sym(ref a0sym) if a0sym == "quasiquote" => {
  184. ast = quasiquote(&l[1]);
  185. continue 'tco;
  186. }
  187. Sym(ref a0sym) if a0sym == "defmacro!" => {
  188. let (a1, a2) = (l[1].clone(), l[2].clone());
  189. let r = eval(a2, env.clone())?;
  190. match r {
  191. MalFunc {
  192. eval,
  193. ast,
  194. env,
  195. params,
  196. ..
  197. } => Ok(env_set(
  198. &env,
  199. a1.clone(),
  200. MalFunc {
  201. eval: eval,
  202. ast: ast.clone(),
  203. env: env.clone(),
  204. params: params.clone(),
  205. is_macro: true,
  206. meta: Rc::new(Nil),
  207. },
  208. )?),
  209. _ => error("set_macro on non-function"),
  210. }
  211. }
  212. Sym(ref a0sym) if a0sym == "macroexpand" => {
  213. match macroexpand(l[1].clone(), &env) {
  214. (_, Ok(new_ast)) => Ok(new_ast),
  215. (_, e) => return e,
  216. }
  217. }
  218. Sym(ref a0sym) if a0sym == "try*" => match eval(l[1].clone(), env.clone()) {
  219. Err(ref e) if l.len() >= 3 => {
  220. let exc = match e {
  221. ErrMalVal(mv) => mv.clone(),
  222. ErrString(s) => Str(s.to_string()),
  223. };
  224. match l[2].clone() {
  225. List(c, _) => {
  226. let catch_env = env_bind(
  227. Some(env.clone()),
  228. list!(vec![c[1].clone()]),
  229. vec![exc],
  230. )?;
  231. eval(c[2].clone(), catch_env)
  232. }
  233. _ => error("invalid catch block"),
  234. }
  235. }
  236. res => res,
  237. },
  238. Sym(ref a0sym) if a0sym == "do" => {
  239. match eval_ast(&list!(l[1..l.len() - 1].to_vec()), &env)? {
  240. List(_, _) => {
  241. ast = l.last().unwrap_or(&Nil).clone();
  242. continue 'tco;
  243. }
  244. _ => error("invalid do form"),
  245. }
  246. }
  247. Sym(ref a0sym) if a0sym == "if" => {
  248. let cond = eval(l[1].clone(), env.clone())?;
  249. match cond {
  250. Bool(false) | Nil if l.len() >= 4 => {
  251. ast = l[3].clone();
  252. continue 'tco;
  253. }
  254. Bool(false) | Nil => Ok(Nil),
  255. _ if l.len() >= 3 => {
  256. ast = l[2].clone();
  257. continue 'tco;
  258. }
  259. _ => Ok(Nil),
  260. }
  261. }
  262. Sym(ref a0sym) if a0sym == "fn*" => {
  263. let (a1, a2) = (l[1].clone(), l[2].clone());
  264. Ok(MalFunc {
  265. eval: eval,
  266. ast: Rc::new(a2),
  267. env: env,
  268. params: Rc::new(a1),
  269. is_macro: false,
  270. meta: Rc::new(Nil),
  271. })
  272. }
  273. Sym(ref a0sym) if a0sym == "eval" => {
  274. ast = eval(l[1].clone(), env.clone())?;
  275. while let Some(ref e) = env.clone().outer {
  276. env = e.clone();
  277. }
  278. continue 'tco;
  279. }
  280. Sym(ref a0sym) if a0sym == "setup" => {
  281. let a1 = l[1].clone();
  282. // todo
  283. ast = eval(a1.clone(), env.clone())?;
  284. // let _pvk = setup(a1.clone(), env.clone())?;
  285. continue 'tco;
  286. }
  287. Sym(ref a0sym) if a0sym == "prove" => {
  288. let a1 = l[1].clone();
  289. ast = eval(a1.clone(), env.clone())?;
  290. prove(a1.clone(), env.clone())
  291. }
  292. Sym(ref a0sym) if a0sym == "alloc-const" => {
  293. let a1 = l[1].clone();
  294. let value = eval(l[2].clone(), env.clone())?;
  295. let result = eval(value.clone(), env.clone())?;
  296. let allocs = get_allocations(&env, "AllocationsConst");
  297. let mut new_hm: FnvHashMap<String, MalVal> = FnvHashMap::default();
  298. for (k, v) in allocs.iter() {
  299. new_hm.insert(k.to_string(), eval(v.clone(), env.clone())?);
  300. }
  301. new_hm.insert(a1.pr_str(false), result.clone());
  302. env_set(
  303. &env,
  304. Sym("AllocationsConst".to_string()),
  305. Hash(Rc::new(new_hm), Rc::new(Nil)),
  306. )?;
  307. Ok(result.clone())
  308. }
  309. Sym(ref a0sym) if a0sym == "alloc-input" => {
  310. let a1 = l[1].clone();
  311. let value = eval(l[2].clone(), env.clone())?;
  312. let result = eval(value.clone(), env.clone())?;
  313. let allocs = get_allocations(&env, "AllocationsInput");
  314. let mut new_hm: FnvHashMap<String, MalVal> = FnvHashMap::default();
  315. for (k, v) in allocs.iter() {
  316. new_hm.insert(k.to_string(), eval(v.clone(), env.clone())?);
  317. }
  318. new_hm.insert(a1.pr_str(false), result.clone());
  319. env_set(
  320. &env,
  321. Sym("AllocationsInput".to_string()),
  322. Hash(Rc::new(new_hm), Rc::new(Nil)),
  323. )?;
  324. Ok(result.clone())
  325. }
  326. Sym(ref a0sym) if a0sym == "alloc" => {
  327. let a1 = l[1].clone();
  328. let value = eval(l[2].clone(), env.clone())?;
  329. let result = eval(value.clone(), env.clone())?;
  330. let allocs = get_allocations(&env, "Allocations");
  331. let mut new_hm: FnvHashMap<String, MalVal> = FnvHashMap::default();
  332. for (k, v) in allocs.iter() {
  333. new_hm.insert(k.to_string(), eval(v.clone(), env.clone())?);
  334. }
  335. new_hm.insert(a1.pr_str(false), result.clone());
  336. env_set(
  337. &env,
  338. Sym("Allocations".to_string()),
  339. Hash(Rc::new(new_hm), Rc::new(Nil)),
  340. )?;
  341. Ok(result.clone())
  342. }
  343. //Sym(ref a0sym) if a0sym == "verify" => {
  344. Sym(ref a0sym) if a0sym == "enforce" => {
  345. // here i'm considering that we always have tuple with only two elements
  346. // also it's important to keep in mind for the sake of brevity of this v0
  347. // we will not allow calculation or any lisp evaluations inside the enforce
  348. // it means that every symbol will be on allocations and we will do the
  349. // find/replace on the bellman circuit, it's nasty v0
  350. let mut left_vec = vec![];
  351. let mut right_vec = vec![];
  352. let mut out_vec = vec![];
  353. // todo extract a macro for this
  354. match l[1].clone() {
  355. List(v, _) | Vector(v, _) => {
  356. if let List(_, _) = &v.to_vec()[0] {
  357. for ele in v.to_vec().iter() {
  358. if let List(ele_vec, _) = ele {
  359. left_vec.push((
  360. ele_vec[0].pr_str(false),
  361. ele_vec[1].pr_str(false),
  362. ));
  363. }
  364. }
  365. } else {
  366. left_vec.push((v[0].pr_str(false), v[1].pr_str(false)));
  367. }
  368. }
  369. _ => {}
  370. };
  371. match l[2].clone() {
  372. List(v, _) | Vector(v, _) => {
  373. if let List(_, _) = &v.to_vec()[0] {
  374. for ele in v.to_vec().iter() {
  375. if let List(ele_vec, _) = ele {
  376. right_vec.push((
  377. ele_vec[0].pr_str(false),
  378. ele_vec[1].pr_str(false),
  379. ));
  380. }
  381. }
  382. } else {
  383. right_vec.push((v[0].pr_str(false), v[1].pr_str(false)));
  384. }
  385. }
  386. _ => {}
  387. };
  388. match l[3].clone() {
  389. List(v, _) | Vector(v, _) => {
  390. if let List(_, _) = &v.to_vec()[0] {
  391. for ele in v.to_vec().iter() {
  392. if let List(ele_vec, _) = ele {
  393. out_vec.push((
  394. ele_vec[0].pr_str(false),
  395. ele_vec[1].pr_str(false),
  396. ));
  397. }
  398. }
  399. } else {
  400. out_vec.push((v[0].pr_str(false), v[1].pr_str(false)));
  401. }
  402. }
  403. _ => {}
  404. };
  405. let enforce = EnforceAllocation {
  406. left: left_vec,
  407. right: right_vec,
  408. output: out_vec,
  409. };
  410. let mut new_vec: Vec<EnforceAllocation> = vec![enforce];
  411. for value in get_enforce_allocs(&env).iter() {
  412. new_vec.push(value.clone());
  413. }
  414. env_set(
  415. &env,
  416. Sym("AllocationsEnforce".to_string()),
  417. vector![vec![Enforce(Rc::new(new_vec))]],
  418. );
  419. /*
  420. println!("\n\nallocations {:?}", get_allocations(&env, "Allocations"));
  421. println!(
  422. "\n\nallocations input {:?}",
  423. get_allocations(&env, "AllocationsInput")
  424. );
  425. println!("\n\nallocations enforce {:?}", get_enforce_allocs(&env));
  426. */
  427. Ok(vector![vec![]])
  428. }
  429. _ => match eval_ast(&ast, &env)? {
  430. List(ref el, _) => {
  431. let ref f = el[0].clone();
  432. let args = el[1..].to_vec();
  433. match f {
  434. Func(_, _) => f.apply(args),
  435. MalFunc {
  436. ast: mast,
  437. env: menv,
  438. params,
  439. ..
  440. } => {
  441. let a = &**mast;
  442. let p = &**params;
  443. env = env_bind(Some(menv.clone()), p.clone(), args)?;
  444. ast = a.clone();
  445. continue 'tco;
  446. }
  447. _ => {
  448. Ok(vector![el.to_vec()])
  449. //error("call non-function")
  450. }
  451. }
  452. }
  453. _ => error("expected a list"),
  454. },
  455. }
  456. }
  457. _ => eval_ast(&ast, &env),
  458. };
  459. break;
  460. } // end 'tco loop
  461. ret
  462. }
  463. pub fn get_enforce_allocs(env: &Env) -> Vec<EnforceAllocation> {
  464. // todo need some cleanup
  465. match env_find(env, "AllocationsEnforce") {
  466. Some(e) => match env_get(&e, &Sym("AllocationsEnforce".to_string())) {
  467. Ok(f) => {
  468. if let Vector(val, _) = f {
  469. if let Enforce(ret) = &val[0] {
  470. ret.to_vec()
  471. } else {
  472. vec![]
  473. }
  474. } else {
  475. vec![]
  476. }
  477. }
  478. _ => vec![],
  479. },
  480. _ => vec![],
  481. }
  482. }
  483. pub fn get_allocations(env: &Env, key: &str) -> Rc<FnvHashMap<String, MalVal>> {
  484. let alloc_hm: Rc<FnvHashMap<String, MalVal>> = Rc::new(FnvHashMap::default());
  485. match env_find(env, key) {
  486. Some(e) => match env_get(&e, &Sym(key.to_string())) {
  487. Ok(f) => {
  488. if let Hash(allocs, _) = f {
  489. allocs
  490. } else {
  491. alloc_hm
  492. }
  493. }
  494. _ => alloc_hm,
  495. },
  496. _ => alloc_hm,
  497. }
  498. }
  499. pub fn setup(_ast: MalVal, env: Env) -> Result<VerifyKeyParams, MalErr> {
  500. let start = Instant::now();
  501. let c = LispCircuit {
  502. params: FnvHashMap::default(),
  503. allocs: FnvHashMap::default(),
  504. alloc_inputs: FnvHashMap::default(),
  505. constraints: Vec::new(),
  506. };
  507. let random_parameters =
  508. groth16::generate_random_parameters::<Bls12, _, _>(c, &mut OsRng).unwrap();
  509. let pvk = groth16::prepare_verifying_key(&random_parameters.vk);
  510. println!("Setup: [{:?}]", start.elapsed());
  511. Ok(VerifyKeyParams {
  512. verifying_key: pvk,
  513. random_params: random_parameters,
  514. })
  515. }
  516. pub fn prove(_ast: MalVal, env: Env) -> MalRet {
  517. let start = Instant::now();
  518. let allocs_input = get_allocations(&env, "AllocationsInput");
  519. let allocs = get_allocations(&env, "Allocations");
  520. let enforce_allocs = get_enforce_allocs(&env);
  521. let allocs_const = get_allocations(&env, "AllocationsConst");
  522. // todo some refactor to improve this
  523. let params = Some({
  524. // todo check if we do need to pass everything like this, its important to
  525. // remember that this function runs after the evaluation, we have all allocs in memory now with all enfores
  526. let circuit = LispCircuit {
  527. params: allocs_const.as_ref().clone(),
  528. allocs: allocs.as_ref().clone(),
  529. alloc_inputs: allocs_input.as_ref().clone(),
  530. constraints: enforce_allocs.clone(),
  531. };
  532. groth16::generate_random_parameters::<Bls12, _, _>(circuit, &mut OsRng)?
  533. });
  534. let verifying_key = Some(groth16::prepare_verifying_key(&params.as_ref().unwrap().vk));
  535. let circuit = LispCircuit {
  536. params: allocs_const.as_ref().clone(),
  537. allocs: allocs.as_ref().clone(),
  538. alloc_inputs: allocs_input.as_ref().clone(),
  539. constraints: enforce_allocs.clone(),
  540. };
  541. let proof = groth16::create_random_proof(circuit, params.as_ref().unwrap(), &mut OsRng)?;
  542. // todo save the proof and keys on a file
  543. let mut vec_input = vec![];
  544. for (k, val) in allocs_input.iter() {
  545. if let MalVal::ZKScalar(v) = val {
  546. vec_input.push(*v);
  547. }
  548. }
  549. println!("vec input {:?}", vec_input);
  550. let result = groth16::verify_proof(
  551. verifying_key.as_ref().unwrap(),
  552. &proof,
  553. vec_input.as_slice(),
  554. );
  555. println!("{:?}", result);
  556. Ok(MalVal::Nil)
  557. }
  558. pub fn verify(_ast: &MalVal) -> MalRet {
  559. let _public_input = vec![bls12_381::Scalar::from(27)];
  560. let start = Instant::now();
  561. println!("Verify: [{:?}]", start.elapsed());
  562. Ok(MalVal::Nil)
  563. }
  564. // print
  565. fn print(ast: &MalVal) -> String {
  566. ast.pr_str(true)
  567. }
  568. fn rep(str: &str, env: &Env) -> Result<String, MalErr> {
  569. let ast = read(str)?;
  570. let exp = eval(ast, env.clone())?;
  571. Ok(print(&exp))
  572. }
  573. fn main() -> Result<(), ()> {
  574. let matches = clap_app!(zklisp =>
  575. (version: "0.1.0")
  576. (author: "mileschet <miles.chet@gmail.com>")
  577. (about: "A Lisp Interpreter for Zero Knowledge Virtual Machine")
  578. (@subcommand load =>
  579. (about: "Load the file into the interpreter")
  580. (@arg FILE: +required "Lisp Contract filename")
  581. )
  582. )
  583. .get_matches();
  584. CombinedLogger::init(vec![TermLogger::new(
  585. LevelFilter::Debug,
  586. Config::default(),
  587. TerminalMode::Mixed,
  588. )
  589. .unwrap()])
  590. .unwrap();
  591. match matches.subcommand() {
  592. Some(("load", matches)) => {
  593. let file: String = matches.value_of("FILE").unwrap().parse().unwrap();
  594. repl_load(file)?;
  595. }
  596. _ => {
  597. eprintln!("error: Invalid subcommand invoked");
  598. std::process::exit(-1);
  599. }
  600. }
  601. Ok(())
  602. }
  603. fn repl_load(file: String) -> Result<(), ()> {
  604. let repl_env = env_new(None);
  605. for (k, v) in core::ns() {
  606. env_sets(&repl_env, k, v);
  607. }
  608. let _ = rep("(def! not (fn* (a) (if a false true)))", &repl_env);
  609. let _ = rep(
  610. "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))",
  611. &repl_env,
  612. );
  613. //let _ = rep("(defmacro! cond (fn* (& xs) (if (> (count xs) 0) (list 'if (first xs) (if (> (count xs) 1) (nth xs 1) (throw \"odd number of forms to cond\")) (cons 'cond (rest (rest xs)))))))", &repl_env);
  614. match rep(&format!("(load-file \"{}\")", file), &repl_env) {
  615. Ok(_) => std::process::exit(0),
  616. Err(e) => {
  617. println!("Error: {}", format_error(e));
  618. std::process::exit(1);
  619. }
  620. }
  621. }