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 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? Correct Answer 𝑇<sub>3</sub>𝑇<sub>3</sub>
Concept:
Take relational algebra which generates the longest subsequence.
With T3 we get a subsequence of 5, and T1 we get a subsequence of only 4, T2 we get a subsequence of only 3.
Hence, T3 preferred over T2 and T1
Explanation
String = ????????
(?|?)∗ = (a + b)*
?? = (ϵ + c)
?3: ?? (?|?)∗?
T3 = bbaac (longest prefix match)
T3= abc
?3?3 = ????? ???
Therefore option 4 is correct