> Parsing Haskell list comprehensions deterministically ((LA)LR) is currently very
> hard, since both "pat <- exp" (or also "pat gd <- exp", as suggested by Thomas)
> and "exp" are allowed as qualifiers in a list comprehension. Patterns and
> expressions can look very much alike. Could one possibly expand "exp" to
> "if exp" in Haskell 1.3 list comprehensions? Only to make deterministic
> parsing easier...
I once had the same problem when writing a Miranda-ish compiler.
The simple solution is to use "exp" instead of "pat" in the parsing
grammar (in qualifiers), and when it later (e.g. encountering <- )
becomes clear that the beast has got to be a pattern,
you check it semantically. This works, because patterns
are syntactically a subclass of expressions.
One should not make the parsing method too much influence the language
design, PASCAL is a bad example for this.
Stefan Kahrs