Computer Science EngineeringHard

When several lexemes could be matched by different Lex rules, Lex picks

  1. A. the longest match, and the earlier rule on a tie
  2. B. the shortest match
  3. C. a random rule
  4. D. the last rule listed

Correct answer: A. the longest match, and the earlier rule on a tie

Lex uses the longest-match principle and breaks ties by rule order.

More Theory of Computation, Compilers & Digital Logic (ISRO CS) questions

Exams that ask this topic