|
File TakeHomeFinal.html
Authors McKeeman
Copyright © 2007
Take Home Final for 10-Lecture Course
X
-
Where does the basic design for X come from?
-
Write and run a short X program to compute
the average of two real numbers.
-
Write and run another short X program to test the first program.
-
What are the primitive concepts of X?
-
What common programming language primitives are omitted?
-
Describe the X subprogram call.
Grammars
- Define the term Context-free Grammar.
- Write a CFG to describe exact change for a dime.
- Repeat the problem, using a different grammar notation
- Repeat the problem, using a different grammar notation
- Define the term Finite Automaton in terms of a CFG.
- Write a FA grammar for change for a dime.
-
Describe briefly how a CFG determines order of expression evaluation.
Lexing
-
Describe the concept of a lexeme.
-
Describe the concept of a token.
-
There is an argument that implies doing all the lexing before
using any of the tokens is efficient. What is the argument?
Parsing
-
What are the roles of the CFG and IOG in parser construction?
-
Describe the process of deriving the IOG from the CFG.
-
The bottom-up parser does not need the IOG. Why?
-
What is the output of the parser?
Trees
-
How is the tree built?
-
Describe the difference between a syntax tree and an AST.
-
Using X.cfg, write down a syntax tree for "x:=1"
-
Using X.cfg, write down an AST for "x:=a*2-2/b"
-
The trees in xcom are read-only.
Why might one like them to be writable?
Symbols
-
What is the purpose of the compiler symbol table?
-
What are the methods of the symbol table object?
-
What is the relation between the symbol table and run-time frame?
-
What error will the X program "x:=y" give?
-
What error will the X program "x:=rand+1" give?
Generator
-
What is the purpose of the generator?
-
How does it work?
Emitter
-
What is the purpose of the emitter?
Assembler
-
What is the purpose of the assembler?
-
Using the mnemonics of xcom,
describe the following instructions as a state change on the CPU.
- addRR EAX,ECX
- faddp
- movMR x,EAX
- movRM EAX,y
- bge n
Emulator
-
What is the purpose of the emulator?
-
The emulator can step ahead and back any number of steps.
How is this done?
Optimization
-
What is the "as if" rule?
-
Give an example of constant folding.
-
Give an example common subexpression elimination.
-
Give an example of hoisting.
-
Why is the X code i := r2i(z); j := i+1; likely
to lead to a successful peephole optimization?
Runtime
-
What is the purpose of the runtime?
-
Describe the run-time frame:
- as a place to keep three types of X variables
- in relation to input and output
- in relation to subprogram linkage
| |