76862

JavaCC: You must either use ReInit() or set the JavaCC option STATIC to false

Question:

i am using eclipse and JavaCC plugin 1.5.27 <br /> 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 <br /> hans

--

Answer1:

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

}

Recommend

  • Problem with jQuery Colorbox
  • Slick jQuery: TypeError Cannot read property 'unslick' of undefined
  • Change the default package name in Swagger Editor for java project
  • complex db2/sql query with time-sampling, group, map, join and csv export
  • Spring boot 2.0.0.M4 required a bean named 'entityManagerFactory' that could not be found
  • How can I set a binding to a Combox in a UserControl?
  • Problems compiling files using JOGL
  • Create DicomImage from scratch using Dcmtk
  • Parsing a CSV string while ignoring commas inside the individual columns
  • How do I access an unhandled exception in an MVC Error view?
  • Swing - Get new component under mouseReleased
  • MVC3 Razor - ListBox pre-select not working
  • Set the selected item in dropdownlist in MVC3
  • Google Custom Search with transparent background
  • how to adjust image in a panel in Java swing?
  • ilmerge with a PFX file
  • Spring Data JPA custom method causing PropertyReferenceException
  • Can I display google adwords (AdView) in javafx on android
  • req.body is undefined - nodejs
  • Validaiting emails with Net.Mail MailAddress
  • sending/ receiving email in Java
  • vba code to select only visible cells in specific column except heading
  • Cannot Parse HTML Data Using Android / JSOUP
  • How to delete a row from a dynamic generate table using jquery?
  • Proper way to use connect-multiparty with express.js?
  • How to set the response of a form post action to a iframe source?
  • JTable with a ScrollPane misbehaving
  • Angular 2 constructor injection vs direct access
  • Change div Background jquery
  • Qt: Run a script BEFORE make
  • How can I remove ASP.NET Designer.cs files?
  • unknown Exception android
  • Checking variable from a different class in C#
  • reshape alternating columns in less time and using less memory
  • costura.fody for a dll that references another dll
  • Binding checkboxes to object values in AngularJs
  • failed to connect to specific WiFi in android programmatically
  • To Get the radio button value in ruby on rails
  • java string with new operator and a literal
  • How can I use threading to 'tick' a timer to be accessed by other threads?