Questions

  1. Show that the following grammar is ambiguous

    S -> aSbS | bSaS | lambda

  2. Consider the grammar:
    Bexpr -> Bexpr OR Bterm | Bterm
    Bterm -> Bterm AND Bfactor | Bfactor
    Bfactor -> NOT Bfactor | ( Bexpr ) | TRUE | FALSE

    * Construct a parse tree for NOT ( TRUE OR FALSE )

  3. Design grammars for the following languages:
    1. Strings of 0's and 1's with an equal number of 0's and 1's
    2. Strings of 0's and 1's of the form xx', where x' is the reverse string of x (ie. if x=001, then xx'=001100)
  4. Design an unambiguous grammar that generates all regular expressions over the symbols a and b. Note that you are generating patterns such as a | b *, not just strings of a's and b's.
Solutions