The action attached to a Lex rule is executed
Answer: A
Correct answer: when the corresponding pattern matches the longest available lexeme
Lex applies two rules in order: match the longest possible lexeme, and where two patterns match a lexeme of the same length, prefer the one written earlier. Only then is the action for the winning rule executed. This is why keyword patterns are written before the identifier pattern - both match if, and order decides.
Please log in or register to report this question.