On Sat, May 13, 2006 at 11:06:27AM +0900, Jeff Pritchard wrote:
> I got it to work, but I couldn't help feeling guilty for sucking the 
> whole bloody file into memory first.  Is there something obvious that I 
> could have done instead that would allow me to look at the file the same 
> way but leave it on disk instead of in memory?

I've done exactly this for a hand-rolled ActionScript parser I wrote.

After having originally gone to painful lengths to make the code
recoginse multi-line tokens while reading the input one line at a time,
I found that converting it to use IO.read made the code both simpler and
faster.  It won't scale well for huge imput files, but who cares?

Maybe StringScanner will work with ruby-mmap, giving the best of both
worlds?  (Won't work under windows though, I expect.)


dave

-- 
http://david.holroyd.me.uk/