[Haskell-beginners] parser error coordinates transformation from preprocessed to original text

Radoslav Dorcik radoslav.dorcik at gmail.com
Sun Sep 18 12:33:34 CEST 2011


The parser function in my library is exposed to user which hides internally
preprocessing & parsing.
When parser error ocurr the coordinates are in preprocessed text, but
library function user deserves to know coordinates in original text.

Following is my application flow (simplified):

{- User exposed library function -}
parseLDIF :: String -> Either ParseError LDIF
parseLDIF xs = myParser $ myPreprocessor xs

{- Expects the preprocessed input -}
myParser :: String -> Either ParseError LDIF

{- Remove comments and unwarp lines; No new text added only removed -}
myPreprocessor :: String -> String

My approach I'm going to implement is to keep information what myProcessor
did on text (some kind of journal of preprocessing).
In the case of error this journal will be used for original text coordinates

myPreprocessor :: String -> (String,[PreprocessorOperation])

Anyway, I have feeling that I'm doing something very wrong... reason for
this email.
What is the common approach to transform error coordinates from preprocessed
to original text ?
Is that common to separate preprocessing & parsing phase ?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/beginners/attachments/20110918/32137132/attachment.htm>

More information about the Beginners mailing list