Com Sci 221/321 --- Programming Languages
Assignment #2 --- Autumn 1999
Due Monday, 11 October
Make sure to follow the
general instructions for
performing and submitting homework.
This homework assignment has no programming
component. Logistically, the nastiest part is drawing trees. You can
do that in plain text, using ASCII symbols such as -, |, /, \
to draw lines. But, this would also be an excellent time to learn some
method for producing PostScript documents.
I recommend that you work all of the problems at the end of Chapter
2 on pp. 49-52 of the text. I have assigned a selection of them.
Com Sci 221 and 321
- Do problems 2.1, 2.2, and 2.3 on p. 49 of the text, but only parts
c, d, and e.
- Do problem 2.6 parts c, d, and e, and 2.7 part e on p. 49 of the text.
- Describe, briefly but precisely, the meaning of each of the
nonterminals <expression>, <term>, and
<factor>. One sentence suffices for each. In this case,
``precisely'' means that your sentence makes it clear exactly which
arithmetic expressions are and are not derived from the given
nonterminal.
- Do problem 2.12 on p. 51 of the text. Your grammar should assign
to each correct C expression a parse tree that corresponds
(after removing ``gimmicks'') to the abstract syntax of the
expression.
- Do problem 2.15 on p. 51 of the text.
- Do problem 2.20 on p. 52 of the text. One or two sentences, plus a
short example, should suffice for your answer.
Com Sci 321 only
- Read Sections 13.1 and 13.2 in the text. Now, consider the
context-free grammar for ``real numbers'' in Figure 2.3, page 36. Of
course, this grammar produces, not real numbers, but strings of
symbols denoting real numbers. Construct an attribute grammar based
on the given context-free grammar to associate the correct numerical
value with each accepted string. Based on this exercise, explain why
the rules for <integer-part> and <fraction> have
different forms.
Last modified: Mon Oct 4 10:19:54 CDT 1999