[Haskell-cafe] Parsec to parse tree structures?

wren ng thornton wren at freegeek.org
Thu Mar 18 22:40:14 EDT 2010


Stephen Tetley wrote:
> hi wren
> 
> Where I've used it, random access does seem conceptual more
> satisfactory than trying to avoid it.

I was thinking more about performance issues (avoiding disk seeks) which 
would also alleviate the problem of needing random access when it's not 
available.


> For complex formats e.g. PECOFF or TrueType, you might only want to
> parse certain tables [*]. After parsing the index table you could
> build a list of parsers to run sequentially on the body of the file
> (including parsers that just drop unwanted tables), but this seems too
> much work (and too much to go wrong)

Even still, you could linearize the access in order to minimize seeking 
back and forth. The linearization could even be done automatically by 
having the table of what needs backpatching also serve as a work queue 
(when done with a block, seek to the closest next block; when the queue 
is empty, you're done). The backpatching queue also preserves structure 
sharing.

Perhaps I've just been parsing too many multigigabyte files lately... :)

-- 
Live well,
~wren


More information about the Haskell-Cafe mailing list