Original Post
I have a small-ish problem when converting a small script language to C++. Most operations are transparent (function calls, operators, etc...) so they can be converted simply by copying them over. My problem occurs when I manipulate variables. I want to convert code as follows:
a + b return a+b;
let a = b T a(b);
in c(a) return c(a);
let a = U b(c);
let b = c V a(d(b));
in d(b) return e(a);
in e(a)
How can I unroll the syntax tree on the left into the sequence of variable initializations on the right? I have no problem with getting the type of any expression, or with generating unique variable names, what I'm stuck on is the actual unrolling of the statements. And I'm pretty sure it can be described easily.