[Haskell-cafe] Layout rule (was Re: PrefixMap: code reviewrequest)

Malcolm Wallace Malcolm.Wallace at cs.york.ac.uk
Mon Mar 6 10:52:19 EST 2006


Daniel Fischer <daniel.is.fischer at web.de> wrote:

> > At the beginning of the module, there is _no_ current indentation
> > level - thus the fourth equation of L applies.
> 
> I think, the third from last equation of L applies, since
> "If the first lexeme of a module is _not_ { or module, then it is
> preceded by  {n} where n is the indentation of the lexeme.", so we
> start L with L ('module':ts) [].

Indeed, and thus, when we get to the end of the first 'where' token, the
stack of indentation contexts is still empty.  Hence my remark about the
fourth equation.

> body		-> { impdecls; topdecls }
> 		| { impdecls }
> 		| { topdecls }
> 
> The first line seems to suggest that import declaraions were
> admissible also  after topdecls, but any attempt to place an impdecl
> after a topdecl leads  --fortunately-- to a parse error in hugs and
> ghc, shouldn't the production be
> 
> body		-> { impdecls }; { topdecls } ?

I think you have mis-read the brace characters as if they were the EBNF
meta symbols for repetition.  They do in fact mean the literal brace
symbol, which may be explicitly present in the source, or inserted by
the layout rule.  Thus, topdecls must follow impdecls, and be at the
same indentation level if layout matters.

Regards,
    Malcolm


More information about the Haskell-Cafe mailing list