What is the primary objective of applying left factoring to a grammar in…

2025

What is the primary objective of applying left factoring to a grammar in compiler design?

  1. A.

    To enhance the grammar's ambiguity and parsing flexibility

  2. B.

    To transform the grammar into its normal form

  3. C.

    To eliminate left recursion from the grammar rules

  4. D.

    To restructure the grammar to aid predictive parsers in making decisions

Attempted by 86 students.

Show answer & explanation

Correct answer: D

Left factoring is a grammar transformation technique used in compiler design to make a Context-Free Grammar (CFG) suitable for deterministic top-down parsing (such as predictive or LL(1) parsing).

When a parser is scanning tokens from left to right, it looks ahead at the incoming token to choose the correct production rule. If multiple rules for a single variable start with the exact same symbols, the parser faces a "backtracking" dilemma because it cannot distinguish between the choices using a limited lookahead. Left factoring resolves this.

Explore the full course: Niacl Ao It Specialist