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

Q. 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 โ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 ๐๐๐๐๐๐๐๐ is processed by the analyzer, which one of the following is the sequence of tokens it outputs?
(A) ๐1๐2๐3ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย (B) ๐1๐1๐3ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย (C) ๐2๐1๐3ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย ย (D) ๐3๐3
Ans: ๐3๐3
Sol:
0 or 1 occurrence of the symbol x. ย T1ย : (b+c)* a + a(b+c)* a T2ย : (a+c)* b + b(a+c)* b T3ย : (b+a)* c + c(b+a)* c Given String : bbaacabc Longest matching prefix is \โย bbaacย \โย (Which can be generated byย T3)ย The remaining part (after Prefix) \โabc\โย (Can be generated byย T3)ย So, the answer isย T3T3ย