What type of grammar is accepted by LEX for token recognition?

2025

What type of grammar is accepted by LEX for token recognition?

  1. A.

    Unrestricted grammar

  2. B.

    Regular grammar

  3. C.

    Context-free grammar

  4. D.

    Context-sensitive grammar

Attempted by 44 students.

Show answer & explanation

Correct answer: B

LEX is a tool used for lexical analysis and token recognition in compiler design. LEX recognizes tokens using regular expressions, which are based on regular grammar. These grammars are suitable for defining patterns such as identifiers, keywords, operators, and numbers.

Explore the full course: Niacl Ao It Specialist