Handling of non-layout sections in HsParser

Simon Marlow simonmar at microsoft.com
Tue Oct 16 05:34:19 EDT 2001


> HsParser fails on any of these 6 examples:
> 
[...]
> 
> The problem seems to be the production (copied from HsParser.ly)
> 
>     > layout_off :: { () }	:	{% pushContext NoLayout }
> 
> This production is supposed to make the parser enter a NoLayout
> context every time the lexer reaches an open brace '{'. It is used in
> other productions such as
> 
>     > decllist :: { [HsDecl] }
>     >	: '{' layout_off decls '}'	{ $3 }
>     >	|     layout_on  decls close	{ $2 }
> 
> For some reason the use of layout_off only takes effect _after_ the
> lexer has produced the next token.

Yes, Happy seems to be grabbing a lookahead token, even though it
doesn't need to.  Anyway, your fix is the right one because it avoids
this non-deterministic behaviour in Happy, and it brings HsParser into
line with the way that GHC's parser works.  

I've committed your patches, thanks!

Cheers,
	Simon




More information about the Glasgow-haskell-bugs mailing list