Send Beginners mailing list submissions to
[email protected]
To subscribe or unsubscribe via the World Wide Web, visit
http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
[email protected]
You can reach the person managing the list at
[email protected]
When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."
Today's Topics:
1. parser error coordinates transformation from preprocessed to
original text (Radoslav Dorcik)
2. Re: parser error coordinates transformation from
preprocessed to original text (Stephen Tetley)
----------------------------------------------------------------------
Message: 1
Date: Sun, 18 Sep 2011 12:33:34 +0200
From: Radoslav Dorcik <[email protected]>
Subject: [Haskell-beginners] parser error coordinates transformation
from preprocessed to original text
To: [email protected]
Message-ID:
<CACvsd6T55V5=zodbcvnbu-p9zcmqo-4rojkgqfufyxbh4w3...@mail.gmail.com>
Content-Type: text/plain; charset="iso-8859-1"
Hi!
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
calculation.
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 ?
Thanks,
Rado
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://www.haskell.org/pipermail/beginners/attachments/20110918/32137132/attachment-0001.htm>
------------------------------
Message: 2
Date: Sun, 18 Sep 2011 17:56:55 +0100
From: Stephen Tetley <[email protected]>
Subject: Re: [Haskell-beginners] parser error coordinates
transformation from preprocessed to original text
Cc: [email protected]
Message-ID:
<cab2tprc3bkqsbco2esqgctc6_xtc_wueegfzg+ebz_efajb...@mail.gmail.com>
Content-Type: text/plain; charset=ISO-8859-1
Hi Radoslav
Comment removal is usually done as part of lexing, so during lexing
you will have access to the true source position - if you care about
line numbering (and have a split between lexing and parsing) usually
you would annotate lexemes with their source position.
If you are doing macro-expansion before parsing and lexing, it is
common to tell the macro expander an artificial but hopefully
correct-to-the-user line number with a pragma like #line.
------------------------------
_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners
End of Beginners Digest, Vol 39, Issue 23
*****************************************