Homework 1 – August
30th - KEY
- Create
a syntactically correct program in mini-language Core using the handout
from class. Program must be
typed. You may work
individually or as a team of two (2) people. Your name(s) must be at the top of the
page along with “Assignment
#1 – August 30th”.
The printout MUST be turned in at the start of Thursday’s class or
it can not be accepted.
Many different possibilities
Simplest:
program
A : integer;
begin
output
A;
end;
Some remarks about the program:
- you
wrote a program in mini-language Core not in BNF
- you
were asked to type the assignment
- you
were asked to have Assignment #1 –
August 30th up top
- does it make sense to have a program with no
output?
Some errors in work turned in
- correct
form of declaration required some
identifier : integer;
- assignment,
input and output statements required semi-colon as terminator
- the
relational operators for less than or equal to and greater than
or equal to do not exist
- the
only case allowed for identifiers is upper case
- identifiers
can not contain digits
- all
non-terminals (“things” in angle
braces) need to be replaced by terminals
- correct
assignment operators is :=
- end
if not endif
- there
is no way to comment in this language
- assignment
statements can only occur after the begin
- ::= and |
are meta-symbols and indicating
replacement or alternation
- variables should be declared – certainly
implied
- if
statement requires parentheses around comparison
- while
statement requires word loop after condition
- programs
are not named (i.e. don’t have identifiers following word program)
if (x = y) then
output x, y;
else
if (x < y) then
output x;
- Buy
the book and bring it to class - The text is Concepts of Programming Languages by Robert W. Sebesta. You may buy either the seventh edition
(which is what the bookstore has) or the previous edition (6th
edition) which you may be able to get used.
- Download
the Force 2.0.8 compiler from the web.
You can locate it
by going keying Force
2.0 into Google and selecting
the item Force – Reviews and free downloads at Download.com . The URL
is www.download.com/Force/3000-2069_4-10233344.html