1
1
Fork 0
mirror of https://github.com/azur1s/bobbylisp.git synced 2024-10-16 02:37:40 -05:00

Compare commits

..

2 commits

Author SHA1 Message Date
Natapat Samutpong 0e992d9324 whoops 2022-02-18 11:31:53 +07:00
Natapat Samutpong c15183ca66 tweaked sexpr gen 2022-02-18 11:31:22 +07:00
4 changed files with 13 additions and 10 deletions

View file

@ -1,9 +1,12 @@
let foo = 1 + 1; let foo = if 1 == 1 then
5
if foo == 2 then
do
foo + 1;
end
else else
foo - 1; 10
end; end;
do
print(1);
end;
fun bar a b = a + b;
let baz = bar(34 35);

BIN
let.cmi

Binary file not shown.

BIN
let.cmo

Binary file not shown.

View file

@ -323,9 +323,9 @@ impl Expr {
&format!("({} {})", name.to_sexpr(), args.iter().map(|x| x.to_sexpr()).collect::<Vec<_>>().join(" "))), &format!("({} {})", name.to_sexpr(), args.iter().map(|x| x.to_sexpr()).collect::<Vec<_>>().join(" "))),
Self::Let{ name, value } => out.push_str( 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( 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( Self::If { cond, then, else_ } => out.push_str(
&format!("(if {}\n {}\n {})", cond.to_sexpr(), then.to_sexpr(), else_.to_sexpr())), &format!("(if {}\n {}\n {})", cond.to_sexpr(), then.to_sexpr(), else_.to_sexpr())),