{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

final_001 - CS 352 Compilers Principles and Practice Final...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
CS 352 – Compilers: Principles and Practice Final Examination, 5/4/10 Instructions: Read carefully through the whole exam first and plan your time. Note the relative weight of each question and part (as a percentage of the score for the whole exam). The total points is 100 (your grade will be the percentage of your answers that are correct). This exam is closed book, closed notes . You may not refer to any book or other materials. You have two hours to complete all five (5) questions. Write your answers on this paper (use both sides if necessary). Name: Student Number: Signature:
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
1. (Compiler phases; 10%) The M3 compiler you worked on this semester manipulates several representations of a program as it is compiled. The initial input is a M3 source program. In the last project you were able to see the output from all the phases of the compiler. Describe the program representations (and any other compile-time data structures) that are generated as output from each of the following compiler phases: (a) scanning (lexical analysis) Answer: tokens (b) parsing (syntactic analysis) Answer: abstract syntax trees (ASTs) (c) type checking (semantic analysis) Answer: annotated ASTs, symbol tables (d) translation (synthesis) Answer: IR trees, frame layout (e) canonicalization (flattening of IR trees) Answer: IR statements (tuples) (f) instruction selection Answer: assembly language instructions (g) control flow analysis Answer: control flow graph (CFG) (h) data flow analysis (liveness) Answer: interference graph (i) register allocation Answer: colored interference graph (j) code generation Answer: assembly language 2
Background image of page 2
2. (Parsing; 30%) Consider the following simple grammar and the language it describes: S ε | a | ( S ) | ( S ; S ) Recall that an LL grammar can be parsed top-down where every derivation stop is predicted by lookahead (as needed). Recall also that an LR grammar can be parsed bottom-up where every reduction step is predicted by lookahead (as needed).
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}