A lexical analyzer uses the following patterns to recognize three tokens T1,…

GATE · 2018 · CS · Computer Science & IT

A lexical analyzer uses the following patterns to recognize three tokens T1, T2, and T3 over the alphabet {a,b,c}.

𝑇1: 𝑎? (𝑏|𝑐)∗𝑎

𝑇2: 𝑏? (𝑎|𝑐)∗𝑏

𝑇3: 𝑐? (𝑏|𝑎)∗ 𝑐

Note that ‘xx?’ means 0 or 1 occurrence of the symbol xx. Note also that the analyzer outputs the token that matches the longest possible prefix.

If the string 𝑏𝑏𝑎𝑎𝑐𝑎𝑏𝑐 is processed by the analyzer, which one of the following is the sequence of tokens it outputs?

  1. A.

    𝑇1𝑇2𝑇3

  2. B.

    𝑇1𝑇1𝑇3

  3. C.

    𝑇2𝑇1𝑇3

  4. D.

    𝑇3𝑇3

Attempted by 331 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…