# HG changeset patch # User Christian Urban # Date 1542667496 0 # Node ID 155430aea517f1aba9484b400e90aa634ca38b04 # Parent 9aa901039e339da9d1bdac90e661495f71e4ce82 updated diff -r 9aa901039e33 -r 155430aea517 handouts/ho08.pdf Binary file handouts/ho08.pdf has changed diff -r 9aa901039e33 -r 155430aea517 handouts/ho08.tex --- a/handouts/ho08.tex Mon Nov 19 22:16:25 2018 +0000 +++ b/handouts/ho08.tex Mon Nov 19 22:44:56 2018 +0000 @@ -1,3 +1,4 @@ +% !TEX program = xelatex \documentclass{article} \usepackage{../style} \usepackage{../langs} @@ -20,11 +21,11 @@ The language we looked at in the previous lecture was rather -primitive and the estimater rather crude---everything was +primitive and the compiler rather crude---everything was essentially estimated into a big monolithic chunk of code inside the main function. In this handout we like to have a look at a slightly more comfortable language, which I call -Fun-language, and a tiny-teeny bit more realistic estimater. +Fun-language, and a tiny-teeny bit more realistic compiler. The Fun-language is a functional programming language. A small collection of programs we want to be able to write and estimate is as follows: @@ -124,7 +125,7 @@ like for the While-language and do not need any modification. (recall that the \textit{estimate}-function for boolean expression takes a third argument for the label where the -contro-flow should jump when the boolean expression is +control-flow should jump when the boolean expression is \emph{not} true---this is needed for compiling \pcode{if}s). One additional feature in the Fun-language are sequences. Their purpose is to do one calculation after another. The @@ -184,7 +185,7 @@ argument-expression of write, which in the While-language was only allowed to be a single variable. -Most of the new code in the estimater for the Fun-language +Most of the new code in the compiler for the Fun-language comes from function definitions and function calls. For this have a look again at the helper function in Figure~\ref{write}. Assuming we have a function definition @@ -268,7 +269,7 @@ else suc(add(x - 1, y)); \end{lstlisting} -\noindent The succesor function is a simple loading of the +\noindent The successor function is a simple loading of the argument $x$ (index $0$) onto the stack, as well as the number $1$. Then we add both elements leaving the result of the addition on top of the stack. This value will be returned by