This is both a Kaz bug fix and a confidence vote for the OP.
In his original answer, Kaz claims Unix lex priority order exactly back. From lex documentation:
Lex can handle ambiguous specifications. When more than one expression can match the current input, Lex selects the following:
The longest match is preferable.
Among the rules that correspond to the same number of characters, the specified rule is first preferable.
In addition, Kaz is mistaken in criticizing the OP solution using Perl-regex word-boundary matching. As it happens, you are allowed (without excruciating guilt) to match the words in any way that your lexer generator supports. CL-LEX uses Perl regular expressions, which use \b as a convenient syntax for the more cumbersome lex approximation:
%{
Other things being equal, the search for a unique match for his words is probably better than an alternative.
Despite the fact that Kaz wanted to pat him, OP answered his question correctly, having come up with a solution that uses the flexibility of his lexer generator.
source share