





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
Main points of this past exam are: Semantic Actions, Abstract Syntax, Tree Data, Data Type, Synthesized, Error Recovery, Follow Sets, Miscellaneous Parsing, Unambiguous Grammar, Discard Actions
Typology: Exams
1 / 9
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 8 pages in this exam and 4 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 20
2 30
3 25
4 25
TOTAL 100
Problem 1: Miscellaneous [20 points]
contains an error but tokenization is still possible. Indicate tokenization by drawing ‘|’ characters between lexemes.
the CYK parser implicitly disambiguates these grammars.
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: Representation Conversions [25 points]
Justification:
Justification: Due to a mistake on our part, we made this problem
harder than originally intended. As a result, all of you got full credit. Some
of you received an extra credit for making good observations about the
wrong grammar.
As some of you noticed, the grammar in the problem was not a correct
RPM grammar. The correct RPN grammar is given above. The (correct)
RPN grammar cannot be expressed as a regular language. Informally, it is
because the grammar generates strings of the form 00+, 000++, 00+0+,
etc, where the ‘+’s, viewed as binary operators, must always have zeros on
the left; these zeros could be results of the evaluations. So there is a
counting argument: one needs to keep track of the generated zeros in
order to generate the right number of ‘+’s. Similar argument applied to the
more complex grammar in the problem.
Problem 4: Grammars and Syntax Directed Translation [25 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{ (^) /\emph{/ open } /}/ close Text /(\[}\]|[^\}]|\n)/*^ Text