CST 8152 Compilers
Pre-Final Exam Review Questions
- See all previous Review Questions and Text Readings.
- Be familiar with the notational conventions for grammars
(4.2).
- Define briefly (4.2,4.5,4.6): handle, leftmost
(rightmost) derivation, operator grammar, positional
precedence, inherent precedence, operator precedence
relations, shift, reduce, ambiguous grammar, left (right)
recursion, a sentential form, a sentence
- Given a grammar and a sentence in the language defined by
the grammar, show the rightmost and leftmost derivations
of the sentence. Show the parse trees corresponding to
the two derivations.
- What is meant by an "LL" parser? What is an
"LR" parser?
- Is top-down parsing LL or LR? What about bottom-up
parsing?
- Can a top-down parser handle: (1) left-recursive
grammars? (2) right-recursive grammars?
- Know how to recognize left recursion in a grammar (2.4,
4.3). Know how to eliminate immediate left
recursion from a grammar (p.176). Why would one want to
do this?
- Know how to complete an operator precedence relation
table given the associativity and precedence of a set of
operators (4.6).
- Know how to use an operator precedence relation table and
a "handle stack" to find and reduce handles
while parsing an input sentence (p.198-199).
- How is left- and right-associativity expressed in an
operator precedence relation table?
- Can an operator precedence parser handle: (1)
left-recursive grammars? (2) right-recursive grammars?
- Define briefly (8.1, 9.1, 9.2): intermediate
representation, target language, quadruple notation,
triple notation (p.470),.
- How are constants handled in a compiler if only addresses
or names can be pushed on the value stack?
- Why use an Intermediate Representation (IR)? Why not
generate the target language (machine code) directly?
- Name the three forms of IR described in class.
- With respect to code generation , why must the symbol
table contain both the type and the address of a name?
Why is the type necessary?
- Given the following expression, show the IR quadruples
that might be generated when the code is compiled.
Variables i,j,k are
integer; x is
floating-point:
i = j * k + j * x
- What changes are needed in the data structures of your
interpreter to turn it into a compiler?
- How do the semantic functions (e.g. execute(op))
differ between an interpreter and a compiler?