[Haskell-cafe] Parsec Scanner Question
jude at pwan.org
Sun Sep 16 14:20:13 EDT 2007
I have an existing Parsec CharParser parser that I would like to extend to
include line continuation support.
When there's a backslash-newline combination anywhere in the token stream,
I'd like to remove it so it's not read by the rest of the parser, even if
its in the middle of a keyword.
Currently I'm doing this with a separate "preprocess" function that weeds
out all the '\\\n' strings from the input before passing it to the parser.
The problem with this is it messes up the line position when there's an
error below the '\\\n' point, since the newline is never seen by the parser.
So I've been trying to figure out how to handle this better with Parsec. I
think I need something that acts just like CharParser, except it skips over
the backslash-newline tokens, It looks like section 2.11 in the Parsec
manual (Advanced: separate scanners") covers this, but I'm not having much
luck turning it into working code.
Could someone who's written their own scanner spell out how it's done in a
little more detail ?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Haskell-Cafe