H98 Report: expression syntax glitch

Ross Paterson ross@soi.city.ac.uk
Mon, 25 Feb 2002 14:48:07 +0000


Consider the following Haskell 98 expressions:

	(let x = 10 in x `div`)
	(let x = 10 in x `div` 3)

To parse the first, a bottom-up parser should reduce the let-expression
before the operator, while to parse the second it should shift.
But it needs 4 tokens of lookahead to decide which to do.  That seems
unreasonable, and is well beyond the LALR(1) parsers used by Hugs and GHC.
Replacing `div` by + needs 2 tokens of lookahead, which is still too much.
I think the first should be made illegal, but can't think of a clean rule.
(There are similar expressions using lambda and if.)