Compilers Questions and Answers – Lexical Analysis – 1

This set of Compilers Multiple Choice Questions & Answers (MCQs) focuses on “Lexical Analysis – 1”.

1. What is the output of lexical analyzer?
a) A set of RE
b) Syntax Tree
c) Set of Tokens
d) String Character
View Answer

Answer: c
Explanation: A lexical analyzer coverts character sequences to set of tokens.

2. Which symbol table implementation is based on the property of locality of reference?
a) Linear list
b) Search tree
c) Hash Table
d) Self Organisation
View Answer

Answer: c
Explanation: Hash table is used as a reference for symbol table because it is efficient.

3. Which of the following is true for operator precedence parsing?
a) For all pair of non-terminal
b) For all pair of non-terminals
c) To delimit the handle
d) None of the mentioned
View Answer

Answer: a
Explanation: There are two important properties for these operator precedence parsers is that it does not appear on the right side of any production and no production has two adjacent non-terminals. Implying that no production right side is empty or has two adjacent non-terminals. So accordingly to property option (A) is correct.
advertisement
advertisement

4. What is an Object program?
a) Program written in machine language
b) Program to be translated into machine language
c) Translation of high-level language into machine language
d) None of the mentioned
View Answer

Answer: c
Explanation: Since the input is the source language and the output that we get after the analysis is the machine language.

5. Which concept of FSA is used in the compiler?
a) Lexical analysis
b) Parser
c) Code generation
d) Code optimization
View Answer

Answer: a
Explanation: Because the lexer performs its analysis by going from one stage to another.
Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

6. Which concept of grammar is used in the compiler?
a) Lexical analysis
b) Parser
c) Code generation
d) Code optimization
View Answer

Answer: b
Explanation: As the lexical analysis of a grammar takes place in phases hence it is synonymous to parser.

7. Which of the following are Lexemes?
a) Identifiers
b) Constants
c) Keywords
d) All of the mentioned
View Answer

Answer: d
Explanation: Different Lexical Classes or Tokens or Lexemes Identifiers, Constants, Keywords, Operators.
advertisement

Sanfoundry Global Education & Learning Series – Compilers.

To practice all areas of Compilers, here is complete set of 1000+ Multiple Choice Questions and Answers.

advertisement

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.