[Haskell] comment vs varsym

Taral taralx at gmail.com
Fri Dec 9 00:38:27 EST 2005

The first token in "--:\n" is...

a) varsym, because varsym always wins according to section 2.3:

An ordinary comment begins with a sequence of two or more consecutive
dashes (e.g. --) and extends to the following newline. The sequence of
dashes must not form part of a legal lexeme. For example, "-->" or
"|--" do not begin a comment, because both of these are legal lexemes;
however "--foo" does start a comment.

or b) comment, because the maximal munch rule says so (it matches the newline):

comment -> dashes [any<symbol> {any}] newline
varsym -> (symbol {symbol | :})<reservedop | dashes>

GHC says comment. Hugs says varsym. What's the answer?

Taral <taralx at gmail.com>
"Computer science is no more about computers than astronomy is about
    -- Edsger Dijkstra

More information about the Haskell mailing list