COSC4307                                         Program-4                               Due: 11/18/2008

                                                FOLLOW Set Computation

Task:

Write a program to compute and print out all FOLLOW sets of non-terminals in a given input Context-Free grammar.

Use the following input grammar.

 

Note: Fnt        =       (R* mn ) T   A mv   L* vt         

 

      Program --> Start Block finish
      Block --->  BEGIN Body END
      Body --->   Body ; S
      Body --->   S
      S --->            Block
      S --->            PRINT Elist
      S --->            READ Vlist
      S --->            IF E THEN S FI
      S --->            IF E THEN S ELSE S FI
      S --->            V = E
      S --->            INTEGER Ilist
      S --->            REAL Ilist
      Ilist --->  Ilist , Id
      Ilist --->  Id
      Ilist --->  Id (Clist )
      Ilist --->  Ilist , Id (Clist)
      Clist --->  Clist , C
      Clist --->  C
      Elist --->  Elist , E
      Elist --->  E
      Vlist --->  Vlist , V
      Vlist --->  V
      V --->            Id
      V --->      Id ( Elist )
      E --->            E + T
      E --->            E - T
      E --->            T
      T --->            T * F
      T --->            F
      T --->            - F
      F --->            C
      F --->            V
      F --->            ( E )