lexer puzzle
Malcolm Wallace
Malcolm.Wallace at cs.york.ac.uk
Mon Sep 15 12:11:38 EDT 2003
Marcin 'Qrczak' Kowalczyk <qrczak at knm.org.pl> writes:
> > > > A...
> > >
> > > A (constructor), then ... (operator).
> > > This is how I understand Haskell 98 lexing rules.
>
> Argh, I was wrong. It's A.. (qualified operator), then . (operator).
You are forgetting about the maximal munch rule. An operator cannot appear
directly next to another operator without some whitespace to separate them.
For instance "A.+." is an operator called (+.) from module A, not an
operator called + followed by compose.
But, although "A...." could be the three-dot operator "..." from the
module A, it is not possible to have "A..." interpreted as a two-dot
operator, because ".." is reserved as sugar for enumeration sequences,
and so is explicitly excluded from the varsym production.
Thus, the only possible lexical interpretation is the one you first
suggested, namely a constructor "A" followed by a three-dot operator
"...".
Regards,
Malcolm
More information about the Haskell
mailing list