lisp.rs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656
  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_vec = get_enforce_allocs(&env);
  406. let enforce = EnforceAllocation {
  407. idx: enforce_vec.len() + 1,
  408. left: left_vec,
  409. right: right_vec,
  410. output: out_vec,
  411. };
  412. let mut new_vec: Vec<EnforceAllocation> = vec![enforce];
  413. for value in enforce_vec.iter() {
  414. new_vec.push(value.clone());
  415. }
  416. env_set(
  417. &env,
  418. Sym("AllocationsEnforce".to_string()),
  419. vector![vec![Enforce(Rc::new(new_vec))]],
  420. );
  421. /*
  422. println!("\n\nallocations {:?}", get_allocations(&env, "Allocations"));
  423. println!(
  424. "\n\nallocations input {:?}",
  425. get_allocations(&env, "AllocationsInput")
  426. );
  427. println!("\n\nallocations enforce {:?}", get_enforce_allocs(&env));
  428. */
  429. Ok(vector![vec![]])
  430. }
  431. _ => match eval_ast(&ast, &env)? {
  432. List(ref el, _) => {
  433. let ref f = el[0].clone();
  434. let args = el[1..].to_vec();
  435. match f {
  436. Func(_, _) => f.apply(args),
  437. MalFunc {
  438. ast: mast,
  439. env: menv,
  440. params,
  441. ..
  442. } => {
  443. let a = &**mast;
  444. let p = &**params;
  445. env = env_bind(Some(menv.clone()), p.clone(), args)?;
  446. ast = a.clone();
  447. continue 'tco;
  448. }
  449. _ => {
  450. Ok(vector![el.to_vec()])
  451. //error("call non-function")
  452. }
  453. }
  454. }
  455. _ => error("expected a list"),
  456. },
  457. }
  458. }
  459. _ => eval_ast(&ast, &env),
  460. };
  461. break;
  462. } // end 'tco loop
  463. ret
  464. }
  465. pub fn get_enforce_allocs(env: &Env) -> Vec<EnforceAllocation> {
  466. // todo need some cleanup
  467. match env_find(env, "AllocationsEnforce") {
  468. Some(e) => match env_get(&e, &Sym("AllocationsEnforce".to_string())) {
  469. Ok(f) => {
  470. if let Vector(val, _) = f {
  471. if let Enforce(ret) = &val[0] {
  472. ret.to_vec()
  473. } else {
  474. vec![]
  475. }
  476. } else {
  477. vec![]
  478. }
  479. }
  480. _ => vec![],
  481. },
  482. _ => vec![],
  483. }
  484. }
  485. pub fn get_allocations(env: &Env, key: &str) -> Rc<FnvHashMap<String, MalVal>> {
  486. let alloc_hm: Rc<FnvHashMap<String, MalVal>> = Rc::new(FnvHashMap::default());
  487. match env_find(env, key) {
  488. Some(e) => match env_get(&e, &Sym(key.to_string())) {
  489. Ok(f) => {
  490. if let Hash(allocs, _) = f {
  491. allocs
  492. } else {
  493. alloc_hm
  494. }
  495. }
  496. _ => alloc_hm,
  497. },
  498. _ => alloc_hm,
  499. }
  500. }
  501. pub fn setup(_ast: MalVal, env: Env) -> Result<VerifyKeyParams, MalErr> {
  502. let start = Instant::now();
  503. let c = LispCircuit {
  504. params: FnvHashMap::default(),
  505. allocs: FnvHashMap::default(),
  506. alloc_inputs: FnvHashMap::default(),
  507. constraints: Vec::new(),
  508. };
  509. let random_parameters =
  510. groth16::generate_random_parameters::<Bls12, _, _>(c, &mut OsRng).unwrap();
  511. let pvk = groth16::prepare_verifying_key(&random_parameters.vk);
  512. println!("Setup: [{:?}]", start.elapsed());
  513. Ok(VerifyKeyParams {
  514. verifying_key: pvk,
  515. random_params: random_parameters,
  516. })
  517. }
  518. pub fn prove(_ast: MalVal, env: Env) -> MalRet {
  519. let start = Instant::now();
  520. let allocs_input = get_allocations(&env, "AllocationsInput");
  521. let allocs = get_allocations(&env, "Allocations");
  522. let enforce_allocs = get_enforce_allocs(&env);
  523. let allocs_const = get_allocations(&env, "AllocationsConst");
  524. //setup
  525. let params = Some({
  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. // prove
  536. let circuit = LispCircuit {
  537. params: allocs_const.as_ref().clone(),
  538. allocs: allocs.as_ref().clone(),
  539. alloc_inputs: allocs_input.as_ref().clone(),
  540. constraints: enforce_allocs.clone(),
  541. };
  542. let proof = groth16::create_random_proof(circuit, params.as_ref().unwrap(), &mut OsRng)?;
  543. let mut vec_input = vec![];
  544. for (k, val) in allocs_input.iter() {
  545. println!("{:?}", val);
  546. if let MalVal::Str(v) = val {
  547. vec_input.push(bls12_381::Scalar::from_string(&v.to_string()));
  548. }
  549. }
  550. let result = groth16::verify_proof(
  551. verifying_key.as_ref().unwrap(),
  552. &proof,
  553. &vec_input,
  554. );
  555. println!("{:?}", result);
  556. println!("vec public {:?}", vec_input);
  557. Ok(MalVal::Nil)
  558. }
  559. pub fn verify(_ast: &MalVal) -> MalRet {
  560. let _public_input = vec![bls12_381::Scalar::from(27)];
  561. let start = Instant::now();
  562. println!("Verify: [{:?}]", start.elapsed());
  563. Ok(MalVal::Nil)
  564. }
  565. // print
  566. fn print(ast: &MalVal) -> String {
  567. ast.pr_str(true)
  568. }
  569. fn rep(str: &str, env: &Env) -> Result<String, MalErr> {
  570. let ast = read(str)?;
  571. let exp = eval(ast, env.clone())?;
  572. Ok(print(&exp))
  573. }
  574. fn main() -> Result<(), ()> {
  575. let matches = clap_app!(zklisp =>
  576. (version: "0.1.0")
  577. (author: "mileschet <miles.chet@gmail.com>")
  578. (about: "A Lisp Interpreter for Zero Knowledge Virtual Machine")
  579. (@subcommand load =>
  580. (about: "Load the file into the interpreter")
  581. (@arg FILE: +required "Lisp Contract filename")
  582. )
  583. )
  584. .get_matches();
  585. CombinedLogger::init(vec![TermLogger::new(
  586. LevelFilter::Debug,
  587. Config::default(),
  588. TerminalMode::Mixed,
  589. )
  590. .unwrap()])
  591. .unwrap();
  592. match matches.subcommand() {
  593. Some(("load", matches)) => {
  594. let file: String = matches.value_of("FILE").unwrap().parse().unwrap();
  595. repl_load(file)?;
  596. }
  597. _ => {
  598. eprintln!("error: Invalid subcommand invoked");
  599. std::process::exit(-1);
  600. }
  601. }
  602. Ok(())
  603. }
  604. fn repl_load(file: String) -> Result<(), ()> {
  605. let repl_env = env_new(None);
  606. for (k, v) in core::ns() {
  607. env_sets(&repl_env, k, v);
  608. }
  609. let _ = rep("(def! not (fn* (a) (if a false true)))", &repl_env);
  610. let _ = rep(
  611. "(def! load-file (fn* (f) (eval (read-string (str \"(do \" (slurp f) \"\nnil)\")))))",
  612. &repl_env,
  613. );
  614. //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);
  615. match rep(&format!("(load-file \"{}\")", file), &repl_env) {
  616. Ok(_) => std::process::exit(0),
  617. Err(e) => {
  618. println!("Error: {}", format_error(e));
  619. std::process::exit(1);
  620. }
  621. }
  622. }