Professional Documents
Culture Documents
Homework Assignment 2
Homework Assignment 2
2024
AAU Klagenfurt / ITEC Taschwer
_________________________________________________________
Homework Assignment 2
Learning goals:
Apply the concepts and methods presented in chapter “top-down parsing” of the lecture
to some exercise problems. These are related to LL(k) grammars and top-down parsers.
Presentation:
Please prepare the solutions for informal presentation in class, and fill in the online check
list in ZEUS.
S -> aA | aB | b
A -> bB | bA
B -> cA | cb
a) Explain why a predictive LL(1) parser cannot be built for this grammar. What is the
minimal lookahead k for G being an LL(k) grammar?
S -> Aa | ac
A -> Sb | Ac | b
a) Identify all (direct and indirect) left recursions in G. Why is a top-down parser not able
to cope with these left recursions?
S -> aAc | cS
A -> dB | bA |
B -> eBa | b
b) Create a parsing table for a predictive non-recursive LL(1) parser for grammar G.
Page 1 of 2
Task 4 Panic mode error recovery
a) Outline the panic mode error recovery technique for LL(1) parsers and describe how
the set of synchronizing tokens of a non-terminal is determined.
b) Represent the process of parsing v = abdedac L(G) in tabular form using the parser
of Task 3 with panic mode error recovery, and determine the corrected word of L(G)
derived by the error handling mechanism.
Page 2 of 2