
Maciej Podgurski
Hi,
I'm currently writing a parser using the Parsec library. What I want is to store the order of each subparser called in a user state. So every single parser will be marked with a label that is stored in a special treelike structure when the parser is run.
My problem is to return the last state of this structure when a parse error occurred. This information shall be used to display a kind of stack trace showing the order of the parser calls for debug purposes. Any ideas how to achieve this?
Write the parser in a way that can never, ever fail, and return the parse error as part of your tree. That is, write a wrapper that puts optionMaybe's around every parser you call and records label, position and everything, and maybe go ahead and roll your own monad inside of ParsecT PS: don't try to influence the parsing based on state, if you don't feel like despairing. Messy cans of worms lay ahead. -- (c) this sig last receiving data processing entity. Inspect headers for past copyright information. All rights reserved. Unauthorised copying, hiring, renting, public performance and/or broadcasting of this signature prohibited.