GATE CS 2018 · Question 47 · Compiler Design · Multiple choice (MCQ) · 2 marks · −2/3 for a wrong answer

A lexical analyzer uses the following patterns to recognize three tokens T₁, T₂, and T₃ over the alphabet {a,b,c}.
T₁: a?(b|c)^*a
T₂: b?(a|c)^*b
T₃: c?(b|a)^*c
Note that 'x?' means 0 or 1 occurrence of the symbol x. Note also that the analyzer outputs the token that matches the longest possible prefix.
If the string bbaacabc is processed by the analyzer, which one of the following is the sequence of tokens it outputs?

  1. (A) T₁T₂T₃
  2. (B) T₁T₁T₃
  3. (C) T₂T₁T₃
  4. (D) T₃T₃
Answer

Answer (D)

Answer from the official GATE CS 2018 answer key.

The step-by-step solution, where available, is part of GATE CS Pro. See what Pro includes