问题
i am using eclipse and JavaCC plugin 1.5.27
i want to use the parser to be executed more than only once. it goes perfect, if using only once. running the parser within the program a second time i get an error:
ERROR: Second call to constructor of static parser.
You must either use ReInit() or set the JavaCC option STATIC to false
during parser generation.
so i add the ReInit() after parsing, but this does not help. this is the code snipped.
public static void myParser(String toanalyze) throws ParseException
{
InputStream is = new ByteArrayInputStream( toanalyze.getBytes() );
SQLwhereS parser = new SQLwhereS(is);
.....
SQLwhereS.one_line();
.....
ReInit(is);
}
looking for all answers from google, but without results. so i am really wondering if i am the only one with this issue.
any help would be great.
kind regards
hans
--
回答1:
As I said in my comment, I generally use nonstatic parser. The following "Answer" is more a guess than an authoritative answer. If you try it, please comment, so others (and I) can know whether it's right.
static SQLwhereS parser = null ;
public static void myParser(String toanalyze) throws ParseException
{
InputStream is = new ByteArrayInputStream( toanalyze.getBytes() );
if( parser==null) parser = new SQLwhereS(is); else ReInit(is) ;
.....
SQLwhereS.one_line();
.....
}
来源:https://stackoverflow.com/questions/22737697/javacc-you-must-either-use-reinit-or-set-the-javacc-option-static-to-false