
On Oct 27, 2010, at 6:23 PM, Claus Reinke wrote:
I'm occasionally working on making a friendly yet performant library that simultaneously builds parsers and generators, but it's non-trivial. If you
I'm probably missing something in the "friendly yet performant" requirements, but I never quite understood the difficulty:
A typical translation of grammar to parser combinators has very little code specific to "parsing" - it is mostly encoding the grammar in a coordination framework that calls on literal parsers at the bottom. Since the coordination framework uses some form of state transformers, exchanging the literal parsers with literal unparsers should turn the grammar parser into a grammar unparser (in essence, the non-terminal code is reusable, the terminal code is specific to the direction of data flow).
On this topic, folks might be interested in the awesome "Invertible Syntax Descriptions" paper presented by Tillmann Rendel and Klaus Ostermann at this year's Haskell Symposium: http://www.informatik.uni-marburg.de/~rendel/unparse/ Cheers, Sterl