Parsing and pretty printed version of the same format in Haskell

I was wondering if in Haskell there is a standard canonical way to write not only a parser for a specific file format, but also an author.

In my case, I need to parse a data file for analysis. However, I also simulate the data that needs to be analyzed and save it in the same format. Now I can write a parser using Parsec or something equivalent, and also write functions that perform text output as needed, but whenever I change my file format, I would have to change two functions in my code. Is there a better way to achieve this?

Thanks Dominik

+7
parsing haskell parsec file-writing
source share
1 answer

BNFC-meta package https://hackage.haskell.org/package/BNFC-meta-0.4.0.3

maybe what you are looking for

"In particular, given the quasi-cited LBNF grammar (as used by BNF Converter), it generates (using Template Haskell) the LALR parser and a pretty nice printer for this language."

+2
source share

All Articles