Primary:
[Skip To Body]
[Front Door]
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Sets:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Miscellaneous:
[2001S]
[98F]
[SamR]
[Glimmer Labs]
Held Monday, September 2, 2002
Summary
Today we consider the basics of compilation by looking at the precise steps that may be involved in translating some sample programs.
Notes
Overview
{ Program: count Purpose: Prints the numbers from 1 to max Author: Samuel A. Rebelsky Version: 1.0 of 26 January 2001 } program count(output); const max = 20; { Procedure: countto Parameters: top, an integer Purpose: Prints the numbers from 1 to top as reals Produces: Nothing Pre: top >= 1 Post: Values have been sidplayed } procedure countto(top: integer); var i: integer; { counter variable } begin for i := 1 to top do writeln(i + 0.0) end; begin countto(max) end.
PROGRAM ID(count) OPEN_PAREN ID(output) CLOSE_PAREN SEMICOLON CONST ID(max) EQUALS NUMBER(20) SEMICOLON PROCEDURE ID(countto) OPEN_PAREN ID(top) COLON TYPE(integer) CLOSE_PAREN VAR ID(i) COLON TYPE(integer) SEMICOLON BEGIN FOR ID(i) ASSIGN NUMBER(1) TO ID(max) DO ID(writeln) OPEN_PAREN ID(i) OPERATOR(+) NUMBER(0.0) CLOSE_PAREN END SEMICOLON BEGIN ID(countto) OPEN_PAREN ID(max) CLOSE_PAREN END PERIOD
program program-head PROGRAM ID(count) OPEN_PAREN file-identifier ID(output) CLOSE_PAREN SEMICOLON block label-declaration empty constant-definition-part CONST constant-definition ID(max) EQUALS constant NUMBER(20) more-constant-defintions empty type-definition-part empty variable-definition-part empty procedure-definition-part ...
program name: ID(count) procedures: ... body: ...
i
is a real number?
max
?
i
after the loop?
Thursday, 29 August 2002
Monday, 2 Septemer 2002
Primary:
[Skip To Body]
[Front Door]
[Current]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Sets:
[EBoards]
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Readings]
[Reference]
ECA:
[About]
[Grades]
[Quizzes]
[Submit Work]
[Change Password]
[Reset Password]
Miscellaneous:
[2001S]
[98F]
[SamR]
[Glimmer Labs]
Disclaimer:
I usually create these pages on the fly
, which means that I rarely
proofread them and they may contain bad grammar and incorrect details.
It also means that I tend to update them regularly (see the history for
more details). Feel free to contact me with any suggestions for changes.
This document was generated by
Siteweaver on Fri Dec 6 10:37:49 2002.
The source to the document was last modified on Mon Sep 2 10:14:31 2002.
This document may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2002F/Outlines/outline.02.html
.
You may wish to
validate this document's HTML
;
;
Check with Bobby