Multiple choice

Which of the following is the correct type checking expression for the given production rule?

E -> (E1, E2)

  1. {E.type = pointer(E1.type)}

  2. {E.type = tuple(E1.type, E2.type)}

  3. {E.type = if (E1.type = arrow(S,T) & E2.type = S) then T else error}

  4. {E.type = if (E1.type = array(S,T) & E2.type = int) then T else error}

  5. {E.type = if E1.type = pointer(T) then T else error}

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

This is the correct type checking expression for the given production rule.