Ithaca College Logo Ithaca College Home Blue Header

Ithaca College, Ithaca, New York
*

In-Class Exercise 1

Due: Thursday, 28 February, end of class.


Objectives:

Reference: Programming Languages, Sebesta, chapter 4. and class slides, chapter 4, part 2.


Instructions:


Problems:

  1. Consider the following grammer. Eliminate left-recursion using the techniques described in class. Capital letters are nonterminals, lowercase terminals. The only BNF symbol is the "or" symbol: |

    Hint: first eliminate the immediate left recursion for each nonterminal, then apply the algorithm given in class, if necessary.

      E -> E + T | T
      
      T -> T * F  | F
      
      F -> id | E id
    

  1. Consider the following grammer. Calculate the FIRST sets for each nonterminal in the grammar. Ensure that there is no pairwise disjointness problem by changing the grammar using the technique described in class. The language described by the grammar will not make sense, but that's ok. Capital letters are nonterminals, lowercase terminals. The only BNF symbol is the "or" symbol: |

      B -> ! id | BE ;  BE
      
      BE -> = id id | > id id | < id id | L
      
      L -> ! BE and BE 
    


Last updated on 27 Feb 2008 by John Barr