Compiler Design Questions and Answers - Syntax Analyser Part-2

1. Which of the following system software resides in the main memory?
a) Text Editor
b) Assembler
c) Linker
d) Loader

Answer: d
Explanation: Loader is used to loading programs.

2. 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
Explanation: This Produce the filr “myfile.yy.c” which we can then compile with g++.

3. Type checking is normally done during ____________
a) Lexical Analysis
b) Syntax Analysis
c) Syntax Directed Translation
d) Code generation

Answer: c
Explanation: It is the function of Syntax directed translation.

4. 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
Explanation: Syntax analyser does not check the type of the operand.

5. In Short Syntax Analysis Generates Parse Tree.
a) True
b) False

Answer: a
Explanation: Short Syntax Analysis generates a parse tree.

6. By whom is the symbol table created?
a) Compiler
b) Interpreter
c) Assembler
d) None of the mentioned

Answer: a
Explanation: Symbol table is created by the compiler which contains the list of lexemes or tokens.

7. 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
Explanation: Syntax analyzer will just create a parse tree. Semantic Analyzer checks the meaning of the string parsed.

8. 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
Explanation: 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).

9. Assume the statements S1 and S2 given as:
S1: Given a context free grammar, there exists an algorithm for determining whether L (G) is infinite.
S2: There exists an algorithm to determine whether two context free grammars generate the same language.
Which of the following is true?
a) S1 is correct and S2 is not correct
b) Both S1 and S2 are correct
c) Both S1 and S2 are not correct
d) S1 is not correct and S2 is correct

Answer: a
Explanation: The proof of S1 can be seen in various book of theory of computation but s2 is a problem of category undecidable so a contradiction to this assumption can be easily obtained.

10. If P & R are regular and also given that if PQ=R, then?
a) Q has to be regular
b) Q cannot be regular
c) Q need not be regular
d) Q has to be a CFL

Answer: c
Explanation: If two regular languages when combined do not always produce a regular language.