JavaCC:您必须使用ReInit()或将JavaCC选项STATIC设置为false [英] JavaCC: You must either use ReInit() or set the JavaCC option STATIC to false

查看:184
本文介绍了JavaCC:您必须使用ReInit()或将JavaCC选项STATIC设置为false的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用eclipse和JavaCC插件1.5.27
我想使用解析器不只执行一次.如果只使用一次,它将非常完美.第二次在程序中运行解析器,我得到一个错误:

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.

所以我在解析后添加ReInit(),但这无济于事. 这是代码片段.

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);
  }

寻找来自Google的所有答案,但没有结果.所以我真的很想知道我是否是唯一遇到此问题的人.

looking for all answers from google, but without results. so i am really wondering if i am the only one with this issue.

任何帮助都会很棒.

亲切的问候
汉斯

kind regards
hans

-

推荐答案

正如我在评论中所说,我通常使用非静态解析器.以下答案"更多是猜测,而不是权威性答案.如果您尝试尝试,请发表评论,以便其他人(和我)可以知道这是否正确.

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();
    .....

}

这篇关于JavaCC:您必须使用ReInit()或将JavaCC选项STATIC设置为false的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆