Institutt for Informatikk
Universitetet i Bergen
I 125 - Innf°ring i Programoversettelse


Voluntary Exercise Set 4 (Gruppe°velser. 4)

  1. Extend the following expression grammar to include the exponentiation operator **. Your grammar should give ** higher precedence then either * or /, and ** should be right associative.

    Exp -> Exp AddOp Term | Term
    AddOp -> + | -
    Term -> Term MultOp Factor | Factor
    MultOp -> * | /
    Factor -> ( Exp ) | num

  2. Exercise 3.12 on page 140 of the text.

  3. Exercise 3.20 on page 141 of the text.

  4. Exercise 4.2 on page 189 of the text.

  5. Exercise 4.3 on page 189 of the text.

  6. Exercise 4.8, part (a) on page 190 of the text.

  7. Exercise 4.10, part (a) on pages 190 and 191 of the text.

  8. Exercise 4.23 on page 192 of the text.

  9. Which operator (* or +) in the grammar below has higher precedence? Remove the left recursion from the grammar.

    Exp -> Exp * N | N
    N -> N + A | A
    A -> $