Compiler Construction
Assign 3: Due 26/3

Top-Down Parsing

  • Show that the following left-factored simplified if-then-else grammar is not LL(1)
  • Investigate the two possibilities to patch the parsing table in the above grammar, and their consequences

    Bottom-Down Parsing

  • Construct an SLR(1) parsing table for the following grammar:
  • Sketch a run of the parser from previous exercise for the input id + id + id. What kind of conclusion can you draw on the impact of right-recursion in LR parsing?
  • Show that the following grammar is LL(1) but not SLR(1)
  • Explain how to resolve conflicts in the following grammar using precedence directives, grammar transformations, and both. Use CUP in your investigations if you like:
  • Give a non-ambiguous grammar that CUP will not be able to parse due to a shift/reduce conflict. Show a particular valid input in the grammar that will not be recognized.