Replies: 2 comments 3 replies
|
Also, to parse the file in parallel, I was looking for statement boundaries and for each chunk found in that way, I constructed an iterator using Is there any other way to do that now? Or should I do on a level above chumsky, always providing it a complete statement to parse? |
I assume, given your use-case, this is because you need the ability to run |
Uh oh!
There was an error while loading. Please reload this page.
So, I've been trying to prototype a parallel parser for the ninja format that can parse big ninja files very fast and at the scale of files I'm testing it on, allocations start to matter quite a bit. So far it was a hand-written parser, but I've been looking at using something like Logos+Chumsky to make it more maintainable.
I tried to write an extension parser using the extension API, but it didn't seem to expose what I needed. In the end I've vendored chumsky into my prototype and added a few methods for that (e.g.
collect_counted_intowhich allows you to count parsed element and allocate the collection yourself), which basically marks the input stream, run a parser once (either a.count()over the base parser or something user-specified if you have a simpler heuristic for knowing how many elements you needs, such as a count of=s only), pre-allocates the collection, reverts to the mark and runs the parser again, pushing the result into the collection, which is then returned as the parse result. It did improve parse times noticeably.I've recently noticed #901 being merged and hoped that means I can finally write it as an extension parser, but it turns out it's not enough for that —
iter_parser.iter_parse()accepts anInputnot anInputRef(and I don't see way to coerce one into the other), whileInputRefonly has aparse, notparse_itermethod.Am I missing some option to do what I want? If not, would extending parser extensions to support such an use case be acceptable?
I suppose #509 is somewhat related, except I don't think it solves the counting part nicely (correct me if I'm wrong)?
All reactions