I am trying to do continuation passing style for a simple programming language made with antlr. Typically you would have an eval procedure that takes as arguments the expression to be evaluated as well as the continuation of that expression. I guess it would be quite elegant to add an additional continuation parameter to the visitor's visit methods (or for the listener).
However, when I generate the parser code with the antlr jar, the visit methods only take one parameter, namely the context (i.e., the tree).
So my question is, how can I add additional parameters to the visit methods such that I get this:
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterStart(Parser.StartContext ctx, Continuation cnt) { }
Instead of the currently auto generated code:
/**
* {@inheritDoc}
*
* <p>The default implementation does nothing.</p>
*/
@Override public void enterStart(Parser.StartContext ctx) { }
If it is not possible to add additional parameters to the visitor's visit methods, how would one accommodate the continuation passing style in antlr?
Thanks a lot!