





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Please read all instructions (including these) carefully. Write your name, login, and SID. No electronic devices are allowed, including cell phones used as watches. Silence your cell phones and place them in your bag. The exam is closed book, but you may refer to one (1) page of handwritten notes. Solutions will be graded on correctness and clarity. Each problem has a relatively simple and straightforward solution. Partial solutions will be graded for partial credit. There are 9 pages in this exam and 5 questions, each with multiple parts. If you get stuck on a question move on and come back to it later. You have 1 hour and 20 minutes to work on the exam. Please write your answers in the space provided on the exam, and clearly mark your solutions. You may use the backs of the exam pages as scratch paper. Do not use any additional scratch paper.
Problem Max points Points
1 17
2 24
3 20 4 15
5 24
TOTAL 100
Problem 1: Miscellaneous [XYZ points]
contains an error but tokenization is still possible. Indicate tokenization by drawing ‘|’ characters between lexemes.
the CYK parser implicitly disambiguates these grammars.
int Fun int id ( P ) { B } P id | P , P E id | E ( A ) A E | E , A B E
int Fun int id ( P ) { B } P id | P , P E id | E ( A ) A E | E , A B E
Problem 3: Left-recursion Elimination [XYZ points]
R -> R '|' R | R '*' | '(' R ')' | 0 | 1
Problem 5: Grammars and Syntax Directed Translation [XYZ points]
The only tricky part is nested emphasis: we want to emphasize text that is already within an emphasized text.
The only tricky part is \emph{nested} emphasis: \emph{we want to emphasize text that is \emph{already within} an emphasized text}.
| The only tricky part is | \emph{ | nested | } | emphasis: | \emph{ | we want to emphasize text that is | \emph{ | already within | } | an emphasized text | } |. |
Lexeme regular expression token \emph{ open } close text Text error -- report error