{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

exam2-2007 - (b The original and modiFed grammars are not...

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

View Full Document Right Arrow Icon
COP5621 Compiler Construction Exam 2 - Spring 2007 Name: (Please print) Put the answers on these sheets. Use additional sheets when necessary. You can collect 100 points in total for this exam. 1. Which of the following terms describes a parsing error recovery strategy? (mark one or more ) (4 points) (a) Viable prefix (b) Error productions (c) Panic mode (d) Left factoring 2. Which of the following strings is recognized by this grammar? (mark one ) (4 points) S a S b b | ε (a) aabb (b) bb (c) aabbbb (d) aaaabb 3. Circle the language relationships between LL(1), LR(0), SLR, LR(1), and LALR(1) gram- mars in a diagram, i.e. which grammars are proper subsets of others or overlap? (7 points) 1
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
4. Consider the grammar: A a A b A | c Give a leftmost derivation of the string aacbcbc . (10 points) 2
Background image of page 2
5. Consider the grammar: A B a | C b B A A C B | a (a) Eliminate left recursion (in general) from the grammar.
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
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: (b) The original and modiFed grammars are not LL(1). Show this for both cases. (5 points) 3 6. Consider the following grammar: FIRST( α ) FOLLOW(A) (1) start → decl stmt (2) decl → type list ; (3) type → int (4) | string (5) list → id more (6) more → , id more (7) | ε (8) stmt → id := expr (9) expr → id (10) | num (a) For each production A → α , determine FIRST( α ) and FOLLOW( A ). (10 points) (b) Construct the LL(1) parsing table. (10 points) 4 7. Consider the grammar: A → C a B a A → B B → C C → b (a) Disprove that the grammar is SLR. (10 points). (b) Construct the LR(1) sets of items. (15 points). (c) Construct the LR(1) parsing table. (15 points). 5...
View Full Document

{[ snackBarMessage ]}