SWE 637 In Class Exercise Number 12B


Consider the following grammar with "expr" as the start symbol.

   expr   ::=  number | expr pair
   number ::= digit digit            // exactly 2 digits 
   pair   ::= number op | number pair op
   op     ::= "+" | "-"  | "*" | "/"
Also consider the following mutation, which adds an additional rule to the grammar:
   pair  ::= number op | number pair op | op number
  1. Mark each of the following strings as either IN or OUT of the (unmutated) grammar:
    ___   1
    ___   12
    ___   12  +  34
    ___   12  34  +
    ___   12  34  56  -  *
    ___   12  34  -  56  *
    ___   12  34  -  56  *  +
    
  2. Find a string (from the list above) that is generated by the mutated grammar, but not by the original grammar.


  3. Find a string (from the list above) that can be generated with the new rule in the mutant grammar, but is also in the original grammar. Demonstrate your answer by giving the two relevant derivations.