EXERCISES
- Check which of the following are LL(1):
(a) S –> A | B A –> aA | a B –> bB | b (b) S –> AB A –> Ba B –> Cb | c C –> c (c) S –> aAaB | bAbB A –> S | cb B –> cB | a
- Have you wondered why we did not discuss LL(k), k > 1 parsers, say LL(2) parsers? Try to form a parsing function M() for LL(2) parser.
- Try to convert the following grammar to a regular expression:
S –> aA B –> bC A –> aA C –> cB A –> aB C –> c
- Show that the following grammar is not LL(1):
V –> S# S –> aAa | empty A –> abS | c
- Give the rules by which you can distinguish the following types of grammars: Regular, LL(1) with and without empty rules, context-sensitive, LR(0) and SLR(1).
- Check if the following grammar is SLR(1) or not:
S –> E# E –> T E –> E;T T –> empty T –> ...
Get Compilers: Principles and Practice now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.