public void checkEnvironment() { // todo give a hint in the message - like "check that no previous version of ANTLR is in your classpath..." // todo message for first-time user to go to tutorial ErrorListener el = ErrorListener.getThreadInstance(); CheckStream bos = new CheckStream(System.err); PrintStream ps = new PrintStream(bos); PrintStream os = System.err; System.setErr(ps); try { ErrorManager.setTool(new Tool()); ErrorManager.setErrorListener(el); } catch (Throwable e) { XJAlert.display(null, "Fatal Error", "ANTLRWorks will quit now because ANTLR reported an error:\n"+bos.getMessage()); System.exit(0); } if(el.hasErrors()) { XJAlert.display(null, "Error", "ANTLRWorks will continue to launch but ANTLR reported an error:\n"+bos.getMessage()); } el.clear(); System.setErr(os); ps.close(); ErrorManager.removeErrorListener(); }
public boolean generate() { ErrorListener el = ErrorListener.getThreadInstance(); ErrorManager.setErrorListener(el); String[] params; if(debug) params = new String[] { "-debug", "-o", getOutputPath(), "-lib", window.getFileFolder(), window.getFilePath() }; else params = new String[] { "-o", getOutputPath(), "-lib", window.getFileFolder(), window.getFilePath() }; new File(getOutputPath()).mkdirs(); Tool antlr = new Tool(Utils.concat(params, AWPrefs.getANTLR3Options())); antlr.process(); boolean success = !el.hasErrors(); if(success) { dateOfModificationOnDisk = window.getDocument().getDateOfModificationOnDisk(); } lastError = el.getFirstErrorMessage(); el.clear(); ErrorManager.removeErrorListener(); return success; }
ErrorManager.setErrorListener(el);
ErrorManager.setErrorListener(el);