Compilers (CS362 2001S)

Class 35: Steps in Compilation, Revisited

Back to Pause for Breath. On to Steps in Compilation, Continued.

Held Wednesday, April 25, 2001


Today we revist the steps involved in compilation by looking at a more complex program in some more detail.



A Sample Program

Here is a sample Pascal program to compute the factorial of a number entered by the user.

program factorial(input,output);
  var val: integer;
  function factorial(n: integer): integer;
    function helper(n: integer; acc: integer): integer;
    begin { factorial/helper }
      if (n = 0) then
        helper := acc
        helper := helper(n-1, acc*n);
    end; { factorial/helper }
  begin { factorial }
    factorial := helper(n, 1);
  end; { factorial}
begin { program }
  write('Please enter a number: ');
  write('The factorial of ');
  write(' is ');
end. { program }

Generating Intermediate Code

Remaining Steps



Monday, 22 January 2001

Wednesday, 25 April 2001


Back to Pause for Breath. On to Steps in Compilation, Continued.

Disclaimer: I usually create these pages on the fly. This means that they are rarely proofread and may contain bad grammar and incorrect details. It also means that I may update them regularly (see the history for more details). Feel free to contact me with any suggestions for changes.

This page was generated by Siteweaver on Mon Apr 30 10:52:13 2001.
This page may be found at
You may validate this page's HTML.
The source was last modified Wed Apr 25 10:52:14 2001.