diff --git a/example/ex.hyc b/example/ex.hyc index ec13856..7bf81af 100644 --- a/example/ex.hyc +++ b/example/ex.hyc @@ -1,9 +1,12 @@ -let foo = 1 + 1; +let foo = if 1 == 1 then + 5 + else + 10 + end; -if foo == 2 then - do - foo + 1; - end -else - foo - 1; -end; \ No newline at end of file +do + print(1); +end; + +fun bar a b = a + b; +let baz = bar(34 35); \ No newline at end of file diff --git a/src/front/parse.rs b/src/front/parse.rs index fd93c1f..60d2f51 100644 --- a/src/front/parse.rs +++ b/src/front/parse.rs @@ -323,9 +323,9 @@ impl Expr { &format!("({} {})", name.to_sexpr(), args.iter().map(|x| x.to_sexpr()).collect::>().join(" "))), Self::Let{ name, value } => out.push_str( - &format!("(let\n {}\n {})", name, value.clone().to_sexpr())), + &format!("(let {}\n {})", name, value.clone().to_sexpr())), Self::Fun{ name, args, body } => out.push_str( - &format!("(fun\n ({})\n {}\n {})", name, args.join(" "), body.to_sexpr())), + &format!("(fun {} ({})\n {})", name, args.join(" "), body.to_sexpr())), Self::If { cond, then, else_ } => out.push_str( &format!("(if {}\n {}\n {})", cond.to_sexpr(), then.to_sexpr(), else_.to_sexpr())),