List out various tasks performed by compiler in converting source code to object code.

CS Professional · Information Technology and Systems Audit · PYQS · December 2017
List out various tasks performed by compiler in converting source code to object code.

Answer & Explanation:

A compiler performs two major tasks: Analysis of the source program Synthesis of the target-language instructions The main tasks carried out by compilers are: Lexing: Break up the text of the program into 'tokens'. Tokens are the 'words' of the programming language, such as identifiers (keywords, variable names, function names, etc.) or operators (=, *, &, etc.). Parsing: Convert the sequence of tokens into a parse tree, which is a data structure representing various language constructs: type declarations, variable declarations, function definitions, loops, conditionals, expressions, etc. Optimization: Evaluate constant expressions, optimize away unused variables or unreachable code, unroll loops if possible, etc. Translate: Translate the parse tree into machine instructions.

Topics: Programming Concepts

Open in Interactive Practice Hub · Full Practice Hub · Chapter Weightage · More in this subject

Related Questions in this Topic