#s causing errors when -cpp not given

Simon Marlow simonmar@microsoft.com
Mon, 28 Jan 2002 17:25:29 -0000


> On Mon, Jan 28, 2002 at 12:31:35PM -0000, Simon Marlow wrote:
> >=20
> > GHC has one small extension to Haskell 98 in this area: the lexical
> > analyser interprets directives line '# 99 "Foo.hs"' at the=20
> beginning of
> > a line in order to get line number and file clues when it=20
> is parsing the
> > output from CPP.  Apart from this, '#' should be=20
> interpreted exactly as
> > per the report (when -fglasgow-exts is off).
>=20
> See below - changing "FOO" to "ifdef FOO" has the same result.
>=20
> [ian@urchin /tmp]$ cat Foo.lhs=20
>=20
> #FOO
>=20
> > main =3D return ()
>=20
> [ian@urchin /tmp]$ ghc Foo.lhs=20
> Foo.lhs:2: parse error on input `#'
> [ian@urchin /tmp]$=20

You're right, it seems that our 'unlit' program (the filter used to
convert a literate file into an illiterate one) leaves lines beginning
with '#' in place.

We could remove this, but I'm not sure how much code it would break.  We
could also do this conditionally based on a flag to unlit which would be
turned on if we're planning to CPP the file, but there's another
problem: sometimes we use {-#OPTIONS -cpp#-} at the top of the file to
indicate that cpp is to be used, so we don't know whether we're going to
be cpp'ing until after we've unlitted the file :-(

Cheers,
	Simon