Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Compilation

COMPILATION:

Compilation is a process  to convert a high-level programming language into a machine language that the computer can understand.
COMPILER:

The software which performs this conversion is called a compiler. Ex. C++ compiler.
PHASES OF COMPILER:
Process of Compilation involves following stages as shown in diagram:
1) Lexical analysis
2) Syntax analysis
3) Semantic analysis
4) Intermediate code generation
5) Code optimization
1) Lexical analysis: This phase scans the program character by character and group these characters in to meaningful words (lexemes).
2) Syntax analysis: This phase takes the output of Lexical analysis phase as input. Than generate the syntax tree (Parse tree) to check program grammar means syntax should be correct.
3) Semantic analysis: This phase checks that in Syntax analysis phase syntax tree constructed follows the rules of language.
For ex. in
int x;
x should store integer value only.
4) Intermediate code generation: In this phase intermediate code of source code is generated. This intermediate code is translated in to machine language.
5) Code optimization: In this phase unnecessary code lines are removed from intermediate code generated.

Viva Voce on Compilation

Q1. What is A Compiler?
Answer :The software which convert a high-level programming language into a machine language is called a compiler. Ex. C++ compiler.

Q2. What are the phases of a compiler?
Answer: Lexical, Syntax, Semantic, Intermediate code generation, Code optimizer.

Q3. What is Symbol Table.
Answer :It is a data structure used by the compiler to keep track of semantics of the variables. It stores information about scope and binding information about names.

Q4. What is Linear Analysis?
Answer :Linear analysis is one in which the stream of characters making up the source program is read from left to right and grouped into tokens that are sequences of characters having a collective meaning.Also called lexical analysis or scanning.

Q5. What Are The Classifications Of A Compiler?
Answer : Single- pass, Multi-pass, Load-and-go, Debugging or optimizing.

Q6. Mention Some Of The Cousins Of A Compiler.
Answer : Preprocessors, Assemblers, Loaders and Link-Editors.

Q7. List the Front End phases of a Compiler.
Answer: Lexical, Syntax, Semantic.

Q8. List the Back End phases of a Compiler.
Answer: Intermediate code generation, Code optimization.

Q9. List The Various Compiler Construction Tools.
Answer : Parser generators, Scanner generators, Syntax-directed translation engines, Automatic code generators

Q10. What is Token?
Answere: Sequence of characters that have a collective meaning.

MCQs on Compilation

Q1. Which of the following software tool is parser generator?
a) Lex
b) Yacc
c) Both of the mentioned
d) None of the mentioned
Q2. A Lex compiler generates
a) Lex object code
b) Transition tables
c) Tokens
d) None of the mentioned
Q3. Compiler can diagnose
a) Grammatical errors only
b) Logical errors only
c) Grammatical and logical errors
d) None of the mentioned
Q4. What is Syntax Analyser also known as
a) Hierarchical Analysis
b) Hierarchical Parsing
c) Hierarchical Analysis & Parsing
MCQs Answers
Q1. (b)
Q2. (b)
Q3. (a)
Q4. (c)

Leave a Comment