Chapter 3: Lexical Analysis

1. Functions and Error Recovery

  • What are the main functions of a lexical analyzer? List the various error recovery strategies in lexical analysis.[2012]

2. Importance of Lexical Analyzer

  • Why is a lexical analyzer essential? Explain.[2015]

3. Tokens

  • What do you mean by a token? Describe different types of tokens.[2021, 17, 12, 10]

4. Token, Pattern, and Lexeme

  • Define token, pattern, and lexeme with examples.[2019, 14, 09]Or,What do you mean by token, lexeme, and identifier?[2011]

5. Buffering in Lexical Analysis

  • Why is buffering used in lexical analysis? What are the commonly used buffering methods?[2021, 17]

6. Input Buffering Techniques

  • Describe the input buffering techniques in detail.[2020, 17]
  • Write down the input buffering technique with code.[2015]Or,How does an input buffer work? Write its code.[2011]

Page 144: Compiler Design and Construction

7. Regular Expressions and Definitions

  • Define a regular expression with an example. What are the rules for constructing regular expressions?[2012]
  • Define a regular definition. Give the regular definition for unsigned numbers in Pascal.[2020, 11]Or,Give the regular definition for unsigned numbers in Pascal and identifiers.[2010]

8. Lexical Syntax

  • Why do we use regular expressions to define the lexical syntax of a language?[2011]

9. Boolean Expressions

  • Briefly describe the principles of representing the value of Boolean expressions.[2013]

10. Precedence Relations

  • How are precedence relations used? Explain a heuristic to produce a proper set of precedence relations.[2011]

11. DFA and NFA

  • What is the difference between DFA and NFA?[2021, 20, 18, 16, 15, 12, 11]
  • Describe NFA and DFA.[2020, 19, 10]

Simplification

12. Designing Automata

  • Design an NFA that accepts the language aa*bb*.[2017]

13. NFA to DFA Conversion

  • Define NFA and DFA. Construct a DFA from the following NFA:[2014]

14. Regular Expression to NFA

  • What is a regular expression? Construct an NFA for the following regular expression: (a|b)abb.[2014]

15. Subset Construction

  • The NFA N accepts the language (a|b)*abb. Construct the DFA using the subset construction rule.[2021, 18]Or,From the following NFA N accepting the language (a|b)*abb, construct the DFA using the subset construction rule.[2016]

16. Regular Expression to DFA

  • Construct a DFA for the regular expression (a|b)abb.[2019, 13, 11, 10]

17. Regular Expressions for Binary Strings

  • Write a regular expression for each of the following sets of binary strings:[2010]
    • (i) All strings containing exactly one 0.
    • (ii) All strings where each 0 is followed by at least one 1.
    • (iii) All strings containing no more than three 0s.
    • (iv) All strings not ending in 01.

18. DFA Construction Algorithm

  • Write down the algorithm for constructing a DFA from a regular expression r.[2021]