On 09 December 2005 05:47, Taral wrote:
On 12/8/05, Taral <taralx@gmail.com> wrote:
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>
Aha. Maximal munch only applies to non-whitespace, so Hugs is right. Yay.
This looks like a mistake in the syntax. I think GHC is following the letter of the spec, but I also think that the intended behaviour was to admit --: as a varsym, i.e. Hugs' behaviour. The syntax allows --: to be a comment, because the class of characters "symbol" does not include :. In contrast, the syntax does *not* admit varsyms beginning with '--' as comments. I'm not aware of maximal munch being applied only to non-whitespace; does it say so anywhere in the report? Cheers, Simon
On 12/12/05, Simon Marlow <simonmar@microsoft.com> wrote:
This looks like a mistake in the syntax. I think GHC is following the letter of the spec, but I also think that the intended behaviour was to admit --: as a varsym, i.e. Hugs' behaviour.
I agree. I suggest modifying the "comment" production to read: comment -> dashes [ any<symbol | :> {any}] newline
I'm not aware of maximal munch being applied only to non-whitespace; does it say so anywhere in the report?
Yes, from section 2.2:
Lexical analysis should use the "maximal munch" rule: at each point, the longest possible lexeme satisfying the lexeme production is read.
Since the "whitespace" production is not included as part of the "lexeme" production, maximal munch must not apply to comments. -- Taral <taralx@gmail.com> "Computer science is no more about computers than astronomy is about telescopes." -- Edsger Dijkstra
participants (2)
-
Simon Marlow -
Taral