Hey guys,
Has anyone had any experience using Parboiled as a push parser?
Right Now I'm using ANTLR to parse an event sequence to generate a list of undo/redo-able actions. It works fairly well, with the one notable exception that, because ANTLR cannot be used as a push parser (at least formally), I have to re-parse the entire event sequence every time a new event comes in. Since antlr is fast this isn't a performance issue so much as a least-suprise issue: in order to create a facade of "new events coming in", we have to perform a logical diff on the resulting parse tree from parse(eventSeq1)
and parse(eventSeq1 + newEvent)
. That diffing logic involves a number of complex caches, and is very bug prone.
I was hoping to replace this parser with parboiled, but it would be hugely convenient to me if I could use parboiled as a push parser.
What I mean by this is as follows: I would write a parboiled grammar and a parse tree visitor. With an empty set of tokens, I would then write parseTree.accept(myVisitor)
. When a new event comes in, I would execute parboiled.tokens += newEvent
. Parboiled would then use any shift/reduce rules it had, in combination with any local stack events (events not consumed by a previous parse), to append any new parse nodes to the existing parse tree, and resume myVisitor
(call any necessary visit methods).
Does this sound feasible?
Thanks for any help!