I am using JavaCC generated parser with spring framework. I define a
singleton instance of my Parser in spring XMl configuration. When I need
to use the parser I need to set it to a new Reader or InputStream. To do
this I needed to add an argument-less constructor and a setInputStream
method as follows:
public FunctionParser() {
}
public void setInputStream(InputStream stream, String encoding) {
//Following is copied from generated constructor with same args
try { jj_input_stream = new SimpleCharStream(stream, encoding,
1, 1); } catch(java.io.UnsupportedEncodingException e) { throw new
RuntimeException(e); }
token_source = new FunctionParserTokenManager(jj_input_stream);
token = new Token();
jj_ntk = -1;
jj_gen = 0;
for (int i = 0; i < 3; i++) jj_la1[i] = -1;
for (int i = 0; i < jj_2_rtns.length; i++) jj_2_rtns[i] = new
JJCalls();
}
This is a hack because the above code copied from generated constructor
with same args changes as grammar changes.
Is there a better way to do this?
--
Regards,
Farrukh
Web:
http://www.wellfleetsoftware.com---------------------------------------------------------------------
To unsubscribe, e-mail:
users-unsubscribe@...
For additional commands, e-mail:
users-help@...