15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

let<br />

fun exp(x,n) =<br />

if n i<br />

| _ => raise Error("Argument expected: " \^ i)<br />

fun lookupP (i,env) =<br />

case lookup(i,env) of<br />

Proc ca => ca<br />

| _ => raise Error("Procedure expected: " \^ i)<br />

c○: Michael Kohlhase 320<br />

Next we define a function that compiles abstract µML expressions into lists of abstract L(VMP)<br />

instructions. As expressions also appear in argument sequences, it is convenient to define a function<br />

that compiles µML expression lists via left folding. Note that the two expression compilers are<br />

very naturally mutually recursive. Another trick we already do is that we give the expression<br />

compiler an argument tail, which can be used to append a list of L(VMP) commands to the result;<br />

this will be useful in the declaration compiler later to take care of the return statment needed to<br />

return from recursive functions.<br />

181

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!