[Haskell-cafe] Layout rule (was Re: PrefixMap: code reviewrequest)
Daniel Fischer
daniel.is.fischer at web.de
Tue Mar 7 09:38:08 EST 2006
Am Montag, 6. März 2006 16:52 schrieb Malcolm Wallace:
> 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.
>
Aha, I read 'At the beginning of the module' as 'at the very beginning',
whereas you meant 'At the beginning, after the module-where', sorry to have
misunderstood.
> > 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.
Ah, damn, fonts are too similar in my browser. And since I've never used
explicit braces at the top level, I didn't expect literal brace-characters
there.
>
> Regards,
> Malcolm
Thanks,
Daniel
--
"In My Egotistical Opinion, most people's C programs should be
indented six feet downward and covered with dirt."
-- Blair P. Houghton
More information about the Haskell-Cafe
mailing list