I was curious if you could support the ability to push tokens into the runtime instead of having to pull with a tokenstream.
I started hacking at it to support it but its more time than i wanted to spend. I was thinking about something like this:
public void parse(Symbol token) throws Exception;
My main goal is to hook up Beaver with Regal (http://www.complang.org/ragel/).
This certainly is possible to implement. However the API has to be somewhat different. Caller/pusher would need to know whether a symbol has been accepted or not (syntax error), or whether it was accepted and the parsing "goal" has been reached.
The only difficulty is error recovery. Even a simple recovery would require a snapshot of the pre-error state, so that parser could be rolled back if an attempted recovery is unsuccessful. All this becomes even more complicated when an error phrase has to be recovered. Currently all these mechanisms are internals of the parser. With push all that would have to be exposed (somehow) to put the caller in control.
Log in to post a comment.