Computer Science 5641
Compiler Design
Homework Assignment 2 (10 points)
Due October 12, 2004

Consider a language defined by the following syntax:

Answer the following questions:

  1. [2] Write a context-free grammar for the language using only one nonterminal.
  2. [1] Is your grammar ambiguous? Explain your answer.
  3. [3] Update your grammar to make a grammar that accounting for the following precedence/associativity information. Operators in order of precedence from highest to lowest are (two operators at the same bullet have highest precedence):
  4. [1] Show a right-most derivation and corresponding parse tree for +++ 5 --+ 3 +-- 4 ++- 6 +-- 2 ---
  5. [3] Determine the first and follow sets for your grammar. Using your sets construct a parse table for a predictive parser.