[Haskell-cafe] Alex and Flex

Manlio Perillo manlio_perillo at libero.it
Fri Oct 3 16:32:23 EDT 2008

Brandon S. Allbery KF8NH ha scritto:
> On Oct 3, 2008, at 09:24 , Manlio Perillo wrote:
>> Manlio Perillo ha scritto:
>>> However I have noted that there are some difference in the syntax 
>>> between Alex and Flex?
>>> What is the rationale?
>> By the way, here is the list of differences between Alex and Flex I 
>> have found, for people interested:
>> 3) Alex does not support
>>       [_a-z0-9-]
>>   that must be rewritten as
>>       [_a-z0-9\-]
> The only *reliable* way to write that cset is to put the '-' as the 
> first item.  Likewise for ']' (and if you must match both, "[-]...]").

Escaping the character solve the problem, or at least I have tested and 
it works.

It seems, however, that Alex is quite strict in accepted characters.

As an example, this rule
     [ \t\r\n\f]

does not match the space character; this character must be escaped:
     [\ \t\r\n\f]

Flex seems to be more "smart", here.

Note that the escaping solve the problem 7):
     \-?@nmstart at nmchar*

Thanks   Manlio Perillo

More information about the Haskell-Cafe mailing list