CS 3723 Programming Languages
Review for Final Exam
Friday, 12 May 2000, 1:30-4:15 pm
Refer to the review for Exam 1
for material in the first part of
the course.
Assignments:
Topics:
- Parsers:
- Construction of top-down recursive descent parsers
(the main technique we used in the course).
- Construction of a bottom-up parser (using ``weak
precedence'' and a simple grammar for arithmetic expressions).
Illustration of how this parser works using a parse stack.
- Translation of AEs to Quadruples (Project III):
- Use of temporary locations.
- Each function of the parser returns an integer. This
integer gives the location of a variable that will hold,
at run time, the value of the construct recognized by the
function.
- Translation of Control Structures to Quadruples (Project IV):
- Translating gotos.
- Backpatching quadruples.
- Translating relational expressions.
- Translating if-else and while-do constructs
(both involving backpatching).
- Implementing functions and parameters:
- Need extensions of the Quadruple machine, at least to include
and indirect JMP.
- Use of a run-time stack of return points to support function
call/return including recursive functions.
- Use of a run-time stack and activation records to support
return addresses, parameters to functions, local variables,
local arrays, value returned by a function, and pointers of
various kinds.
- Run-time storage management:
- The Burroughs machine used a hardware stack, which turns
out to be a poor allocation of hardware resources.
- Constrast C, C++, and Java with respect to:
simple variables, arrays, structs (or classes, parameters,
return values, assignment operator, static variables,
dynamic allocation, dynamically allocating primitive types
(C/C++ yes, Java no except in type-wrapper classes),
allocating arrays, automatic initialization, recovering
dynamic storage (C uses free, C++ uses new, Java automatic
with garbage collection).
- Static and global variables declared in a separate area.
- Local variables on the stack.
- New (or malloced) objects in a separate area (called the
heap).
- Postscript:
- A 2-dimensional page description language.
- Allows the font characters themselves to be described algorithmically
and manipulated.
- Provides many good primitives for drawing 2-dim figures.
- Postscript Programs
- Prolog:
Sample Questions:
- About parsers:
- Given a parser, say what it is doing (and how).
- Write a parser for a simple example language.
- Translating AEs to quads:
- Explain how the returned addresses of run-time
variables work. (Variables which will hold the desired
value at run time.)
- Given some semantic actions, say how they are working.
- Given a parser, create semantic actions to do some simple
task.
- Translating control stuctures:
- Describe how the backpatching works.
- Actually do the translation for some simple example.
- Functions and parameters:
- Show the activation records used at run-time on a stack. Explain.
- Run-time storage management:
- Explain how and when the run-time stack is used.
- Explain about the heap, including garbage collection.
- Postscript:
- Given a simple example program, answer questions about it.
- Prolog:
- Given a simple example program, answer questions about it.
Revision Date: 5/3/00