I've got a file that I want to parse with Treetop. If I wanted to parse the entire thing, I'd use
rule document
category_listing*
end
I don't really want to read the entire file into memory at once. I know I can set up the parser to parse one category_listing
at a time (using #consume_all_input = false
and #root = :category_listing
), which is half the problem. However, it looks like #parse
expects to be passed a String
(and it certainly fails when I try to pass it a File
), which makes the idea of reading and parsing category_listing
by category_listing
sound like a PITA.
Can Treetop only be used to parse String
s? I've been poking around the treetop docs, but haven't found anything definitive.