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

Discussion

Consider the following statements regarding the front-end and back-end of a compiler.

S1: The front-end includes phases that are independent of the target hardware.
S2: The back-end includes phases that are specific to the target hardware.
S3: The back-end includes phases that are specific to the programming language used in the source code.

Identify the CORRECT option.

  • A.Only S1 is TRUE.
  • B.Only S1 and S2 are TRUE.
  • C.S1, S2, and S3 are all TRUE.
  • D.Only S1 and S3 are TRUE.

Answer: B

The answer is only S1 and S2 are TRUE.

A compiler's front-end (lexical analysis, parsing, semantic analysis and intermediate code generation) works on the source language and produces a machine-independent intermediate representation, so it does not depend on the target hardware (S1). The back-end (machine-dependent optimisation, register allocation, instruction selection and code generation) translates that intermediate form for a particular processor, so it is specific to the target hardware (S2).

S3 is false: it is the front-end that is specific to the programming language. The point of the split is that one back-end can serve several source languages and one front-end several targets. That rules out 'Only S1', 'all three' and 'S1 and S3'.

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

Post your comment

Please log in or register to post a comment.