TL;DR: Is there a simple way for me to get the input stream consumed by a parser? Perhaps there is a way using the getInput, getPosition, and parsecMap utilities provided by parsec?
I have a lexer that parses a list of tokens. Each of these tokens are a parse tree ADT. I need to convert some of the tokens back into the stream that was consumed when I parsed the token. However, I would like to avoid writing tons of code to deconstruct the parse trees. I also do not want to change the code of every parser, only the top level ones (I am using recursive descent.)
I want a simple way to get the portion of a stream that is consumed by a parser. In case it matters, I am parsing Char tokens from a String (or [Char], however you prefer). I tried to find a combinator in the parsec documentation for this purpose, but I found none. I know I could change all of the parsers to return the strings they consume and the parse tree in a tuple, but I would rather not rewrite all of those parsers.
Is there a simple way for me to get the input stream consumed by a parser? Perhaps there is a way using the getInput, getPosition, and parsecMap utilities provided by parsec?
Thank you for reading this far! Let me know if I need to clarify or give more details. Cheers!