Questions

  1. Compute first and follow sets for the following grammars:
    1. S -> A B c
      A -> a | lambda
      B -> b | lambda
      
    2. S -> A b
      A -> a | B | lambda
      B -> b | lambda
      
    3. S -> A B B A
      A -> a | lambda
      B -> b | lambda
      
    4.  
      S -> a S e | B
      B -> b B e | C
      C -> c C e | d
      
  2. For the following grammar:
    Expr		-> - Expr  |  ( Expr )  | Var ExprTail             (1-3)
    ExprTail 	-> - Expr | lambda                                 (4-5)
    Var 		-> ID VarTail                                      (6)
    VarTail 	-> ( Expr )  | lambda                              (7-8)
    
    1. Construct the LL(1) predictive parse table
    2. Show execution on input ID - - ID (( ID ))
  3. For the grammar:
    S -> Aa  | b
    A -> bdC  |  C
    C -> abC  | cC  | lambda
    
    1. compute the first and follow and build the predictive parse table.
    2. Trace the execution of the iterative parsing algorithm on input: bdcca
  4. Transform this grammar to LL(1)
    DeclList 	-> DeclList ; Decl  |  Decl
    Decl		-> IdList : Type
    IdList		-> IdList , ID  |  ID
    Type		-> ScalarType  |  array ( ScalarTypeLst) of Type
    ScalarType	-> ID  |  Bound .. Bound
    Bound		-> Sign INTLIT  | ID
    Sign		-> + | - | lambda
    ScalarTypeList	-> ScalarTypeList , ScalarType  |  ScalarType
    
Solutions