Leonard Siebeneicher wrote:
Dear reader,

I wonder whether there is a 'general' working solution to include files
within a parsec parser. Without the need of unsafePerformIO.
At least in parsec 2, I don't think so. Our solution was to read in the main file, tokenise it (using Alex), preprocess it (using some regex-like pattern matching on the token stream) in the IO monad and include the new files then (also tokenising and preprocessing them). Then after preprocessing we feed the entire resulting token stream to Parsec. Whether a two-phase approach (preprocess then parse) works depends on whether your include syntax is simple enough that you can spot the includes without parsing.

Thanks,

Neil.

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to