[Haskell-cafe] Re: Parsec and network data
apfelmus
apfelmus at quantentunnel.de
Sat Aug 30 03:48:37 EDT 2008
Johannes Waldmann wrote:
> Imagine you're writing a parser for a simple programming language.
> A program is a sequence of statements.
> Fine, you do "readFile" (once) and then apply a pure Parsec parser.
>
> Then you decide to include "import" statements in your language.
> Suddenly the parser needs to do IO. Assume the import statements
> need not be the first statements of the program
> (there may be headers, comments etc. before).
> Then you really have to interweave the parsing and the IO.
>
> If anyone has a nice solution to this, please tell. - J.W.
Design your language in a way that the *parse* tree does not depend on import
statements? I.e. Chasing imports is performed after you've got an abstract
syntax tree.
Regards,
apfelmus
More information about the Haskell-Cafe
mailing list