Compilers Multiple Choice Questions & Answers (MCQs) on “Syntax Analyser”.
1. Select a Machine Independent phase of the compiler.
a) Syntax Analysis
b) Intermediate Code generation
c) Lexical Analysis
d) All of the mentioned
Answer: d
Clarification: All of them work independent of a machine.
2. A system program that combines the separately compiled modules of a program into a form suitable for execution?
a) Assembler
b) Compiler
c) Linking Loader
d) Interpreter
Answer: c
Clarification: A loader which combines the functions of a relocating loader with the ability to combine a number of program segments that have been independently compiled.
3. Which of the following system software resides in the main memory?
a) Text Editor
b) Assembler
c) Linker
d) Loader
Answer: d
Clarification: Loader is used to loading programs.
4. Output file of Lex is __________ the input file is Myfile.
a) Myfile.e
b) Myfile.yy.c
c) Myfile.lex
d) Myfile.obj
Answer: b
Clarification: This Produce the filr “myfile.yy.c” which we can then compile with g++.
5. Type checking is normally done during ____________
a) Lexical Analysis
b) Syntax Analysis
c) Syntax Directed Translation
d) Code generation
Answer: c
Clarification: It is the function of Syntax directed translation.
6. Suppose One of the Operand is String and other is Integer then it does not throw error as it only checks whether there are two operands associated with ‘+’ or not.
a) True
b) False
Answer: a
Clarification: Syntax analyser does not check the type of the operand.
7. In Short Syntax Analysis Generates Parse Tree.
a) True
b) False
Answer: a
Clarification: Short Syntax Analysis generates a parse tree.
8. By whom is the symbol table created?
a) Compiler
b) Interpreter
c) Assembler
d) None of the mentioned
Answer: a
Clarification: Symbol table is created by the compiler which contains the list of lexemes or tokens.
9. What does a Syntactic Analyser do?
a) Maintain Symbol Table
b) Collect type of information
c) Create parse tree
d) None of the mentioned
Answer: c
Clarification: Syntax analyzer will just create a parse tree. Semantic Analyzer checks the meaning of the string parsed.
10. Semantic Analyser is used for?
a) Generating Object code
b) Maintaining symbol table
c) Generating Object code & Maintaining symbol table
d) None of the mentioned
Answer: c
Clarification: Maintaining the Symbol Table for each block.
Source Program for Semantic Errors.
Collects Type Information for Code Generation.
Reporting compile-time errors in the code Generating the object code (e.g., assembler or intermediate code).