Back to Source and Target Languages. On to Introduction to Lexical Analysis and Regular Expressions.
Held Friday, January 26, 2001
Summary
Today we consider revisit the basics of compilation by looking at the precise steps that may be involved in translating some sample programs.
Due
Notes
Overview
{ Program: count.
Purpose: Count from 1 to max
Author: Samuel A. Rebelsky
Version: 1.0 of 26 January 2001
}
program count(output);
const max = 20;
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?
Back to Source and Target Languages. On to Introduction to Lexical Analysis and Regular Expressions.
[Current]
[Discussions]
[Glance]
[Honesty]
[Instructions]
[Links]
[Search]
[Syllabus]
Primary
[Examples]
[Exams]
[Handouts]
[Homework]
[Labs]
[Outlines]
[Project]
[Quizzes]
[Readings]
[Reference]
Sets
[Blackboard]
[98F]
Links
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:51:44 2001.
This page may be found at http://www.cs.grinnell.edu/~rebelsky/Courses/CS362/2001S/outline.03.html.
You may validate
this page's HTML.
The source was last modified Mon Jan 22 10:39:10 2001.