COMP3173 Assignment 2 Syntax Analysis
Given the set of tokens (pay attention to the underline “_”) and the following CFG grammar
and answer the following questions. Show the detail of each step.
1. Use the grammar to do left-most and right-most derivation on the input “” and draw the parse tree.(12 pt)
2. Eliminate the left recursions. (6 pt)
3. Base on the grammar without left recursions from Q2, left factorize the grammar. (6 pt)
4. Base on the grammar from Q3, find the set and the set. (10 pt)
5. Base on the grammar from Q3, construct the parsing table. (8 pt)
6. Base on the original grammar, construct the DFA from the set of items. (18 pt)
7. Convert the DFA from Q6 to an parsing table. (15 pt)
8. Use the parsing table to parse “”. Show the configuration and the output for each step. (10 pt)
Given the grammar
1.
2.
9. Show that the grammar is ambiguous. (6 pt)
10. Find a sentence in the language such that the sentence is ambiguous but left-most derivation and right-most derivation can produce a same parse tree. You need to prove your answer. (9 pt)
请加QQ:99515681 邮箱:99515681@qq.com WX:codinghelp