0% found this document useful (0 votes)
61 views

CS8602 Compiler Design UNIT 3 MCQ

The document contains a set of multiple choice questions related to compiler design topics like lexical analysis, syntax analysis, semantic analysis, symbol tables, parsing, intermediate code generation, code optimization. The questions cover concepts like type checking, attribute grammars, syntax trees, intermediate representations like 3-address code, back patching algorithms and functions used during code generation.

Uploaded by

yaminishrvani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

CS8602 Compiler Design UNIT 3 MCQ

The document contains a set of multiple choice questions related to compiler design topics like lexical analysis, syntax analysis, semantic analysis, symbol tables, parsing, intermediate code generation, code optimization. The questions cover concepts like type checking, attribute grammars, syntax trees, intermediate representations like 3-address code, back patching algorithms and functions used during code generation.

Uploaded by

yaminishrvani
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

www.edubuzz360.

com
ChettinadTech Dept of CSE

Department of Computer Science and Engineering


CS8602 Compiler Design

Unit III - MCQ Bank

1. Type checking is normally done during ____________


A. Lexical Analysis
B. Syntax Analysis
C. Syntax Directed Translation
D. Code generation

Answer: (C)

2. Suppose One of the Operand is String and other is Integer then parser does not throw error as it
only checks whether there are two operands associated with ‘+’ or not.
A. True
B. False

Answer: (A)

3. By whom is the symbol table created?


A. Compiler
B. Interpreter
C. Assembler
D. None of the mentioned

Answer: (A)

CS8602 – Compiler Design Page 1

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

4. What does a Syntactic Analyzer do?


A. Maintain Symbol Table
B. Collect type of information
C. Create parse tree
D. None of the mentioned

Answer: (C)

5. Semantic Analyzer 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)

6. Inherited attribute is a natural choice in ___________


A. Variable declarations record is maintained
B. L values and R values
C. All of the mentioned
D. None of the mentioned

Answer: (A)

7. Input to code generator is __________


A. Source code
B. Intermediate code
C. Target code
D. All of the mentioned

Answer: (B)

8. A synthesized attribute is an attribute whose value at a parse tree node depends on __________
A. Attributes at the siblings only

CS8602 – Compiler Design Page 2

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

B. Attributes at parent node only


C. Attributes at children nodes only
D. None of the mentioned

Answer: (C)

9. In a bottom up evaluation of a syntax direction definition, inherited attributes can __________


A. Always be evaluated
B. Be evaluated only if the definition is L –attributed
C. Evaluation only done if the definition has synthesized attributes
D. None of the mentioned

Answer: (C)

10. Which of the following component is important for semantic analysis?

A. Yacc
B. Lex
C. Symbol Table

D. Type Checking

Answer: (D)

11. In the compiler, the function of using intermediate code is:

A. To improve the register allocation


B. To increase the error reporting & recovery.
C. To make semantic analysis easier.

D. To increase the chances of re-using the machine-independent code optimizer in other


compilers.

Answer: (D)

12. The compiler can detect what type of errors?


CS8602 – Compiler Design Page 3

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

A. neither logical nor grammatical error


B. logical errors only

C. grammatical errors only


D. both grammatical and logical errors

Answer: (C)

13. Which of the following are labeled by operator symbol?

A. Root
B. Interior nodes
C. Leaves
D. Nodes

Answer: (B)

14. In which of the following tree, the leaf indicates the operand, and the interior node represents the
operator.

A. Syntax tree
B. Parser tree
C. Structured tree
D. Sematic tree

Answer: (A)

15. Which statement is an abstract form of intermediate code?

A. 3- address
B. 2-address
C. address
D. Intermediate code

CS8602 – Compiler Design Page 4

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

Answer: (A)

16. Which mapping is described by the implementation of the syntax-directed translator?

A. Parse table
B. Input
C. Output
D. Input-Output

Answer: (D)

17. To generate new symbolic label _____ function is used?

A. gen_code()
B. emit()

C. new_label()
D. lookup()

Answer: (C)

18. Identify the function which generates three-address code.

A. gen_code()
B. emit()
C. new_label()
D. lookup()

Answer: (B)

19. Which function is used to check whether the identifier is in symbol table?

A. gen_code()
B. emit()

CS8602 – Compiler Design Page 5

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

C. new_label()
D. lookup()

Answer: (D)

20. Identify the function which returns a new temporary variable?

A. gen_code()
B. emit()

C. new_temp()
D. lookup()

Answer: (C)

21. Back patching Algorithms perform only two operations such as mergelist() and backpatch()

A. True
B. False

Answer: (B)

22. Identify the correct statement

A. makelist (i) – creates a new list containing only i and returns a pointer to the list it has made.
B. Merge (i, j) – concatenates the lists pointed to by i and j, and returns a pointer to the
concatenated list.
C. Backpatch (p, i) – inserts i as the target label for each of the statements on the list pointed to
by p.

D. All the mentioned

Answer: (D)

23. Identify the correct statement

CS8602 – Compiler Design Page 6

https://play.google.com/store/apps/details?id=com.sss.edubuzz360
www.edubuzz360.com
ChettinadTech Dept of CSE

A. Back Patching is putting the address instead of labels when the proper label is determined.
B. Back patching is the activity of filling up the unspecified information of labels by using the
appropriate semantic expression in during the code generation process.
C. It is done by Boolean expression.

D. All the mentioned

Answer: (D)

24. The three address code is a combination of assignment and a binary operator.

A. True

B. False

Answer: (B)

25. Identify the incorrect statement about three address code.

A. It is not used by the optimizing compilers.


B. The instructions was hard to translate into assembly language.
C. Each Three address code instruction has at least three operands.
D. All the mentioned

Answer: (D)

CS8602 – Compiler Design Page 7

https://play.google.com/store/apps/details?id=com.sss.edubuzz360

You might also like