Machine-translated by Google. Questions are authored in English.
Top

Discussion

Type checking is naturally expressed as a syntax directed translation because

  • A.the type of an expression depends on whichever target machine is chosen
  • B.type checking must be performed before the parse has begun
  • C.the type of an expression is synthesised from those of its operands
  • D.types are inherited from the enclosing statement in every case

Answer: C

Correct answer: the type of an expression is synthesised from those of its operands

The type of a sum follows from the types of its two operands, which follow from theirs, all the way down to the identifiers and constants. That is a purely synthesised computation, so type checking fits an S-attributed definition and can be done during a bottom up parse.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.