[Haskell-cafe] Alex and Flex

Manlio Perillo manlio_perillo at libero.it
Fri Oct 3 09:24:00 EDT 2008


Manlio Perillo ha scritto:
> Hi.
> 
> I'm starting to write a CSS parser with Alex and Happy.
> The grammar is defined here:
> http://www.w3.org/TR/CSS21/grammar.html
> 
> However I have noted that there are some difference in the syntax 
> between Alex and Flex?
> What is the rationale?
> 
> 
> One more thing.
> Here: http://www.haskell.org/alex/doc/html/alex-files.html
> it seems that there is an error with
> macrodef  :=  @smac '=' set
>            |  @rmac '=' regexp
> 
> it should be
> macrodef  :=  $smac '=' set
>            |  @rmac '=' regexp
> 

Ok, this is not an error, sorry.


By the way, here is the list of differences between Alex and Flex I have 
found, for people interested:

1) Alex make a distinction between "character set macros" and
    "regular expression macros".
2) Alex support the
        set '#' set0
    syntax for "character set macros"
3) Alex does not support
        [_a-z0-9-]
    that must be rewritten as
        [_a-z0-9\-]
4) In Alex the order of macro definitions is important.
    A macro must be defined before it is used in another macro
    definition.
5) For reasons I still don't understand, this:
        \"([^\n\r\f\\"]|\\@nl|@escape)*\"
    cause a parse error, but these are ok:
        \'([^\n\r\f\\']|\\@nl|@escape)*\'
        \"([^\n\r\f\\"]|\\@nl|@escape)*
6) As with 3), these are not parsed:
        [^*]
        [^/*]
    and must be rewritten as
       [^\*]
       [^\/\*]
7) I don't understand why, but this is not parsed:
       -?@nmstart at nmchar*
    The -? at the beginning must be removed.

    How can I fix this?



Thanks  Manlio Perillo


More information about the Haskell-Cafe mailing list