[Haskell-cafe] A very nontrivial parser
Andrew Coppin
andrewcoppin at btinternet.com
Thu Jul 5 13:47:17 EDT 2007
Malcolm Wallace wrote:
> I can't help thinking that all you really want to do is parse the same
> data twice, through an intermediate representation. That only requires
> you to feed the result of one parse into a top-level call to a different
> parser. For instance:
>
> this = do
> tmp <- parser1
> x <- return (runParser parser2 bar tmp)
> y <- parser3
>
> ... = runParser this foo input
>
> In the example, 'parser2' takes a different state type, and a different
> source token representation from 'parser1' and 'parser3'. No fearsome
> stack type is needed. :-)
>
For the Nth time... The amount of data processed by parser1 needs to
depend on the amount of data processed by parser2. (The amount of data
output by each parser is very nontrivially related to the amount of data
consumed.)
How do you propose to pull that off?
More information about the Haskell-Cafe
mailing list