use of org.antlr.Tool in project antlrworks by antlr.
the class HelpManager method sendFeedback.
public static void sendFeedback(Container parent) {
StringBuilder url = new StringBuilder(Localizable.getLocalizedString(Localizable.FEEDBACK_URL));
url.append("?ANTLRVersion=");
url.append(XJUtils.encodeToURL(new Tool().VERSION));
url.append("&StringTemplateVersion=");
url.append(XJUtils.encodeToURL(StringTemplate.VERSION));
url.append("&ANTLRWorksVersion=");
url.append(XJUtils.encodeToURL(XJApplication.getAppVersionShort()));
url.append("&OS=");
url.append(XJUtils.encodeToURL(XJSystem.getOSName()));
url.append("&JavaVersion=");
url.append(XJUtils.encodeToURL(XJSystem.getJavaRuntimeVersion()));
try {
BrowserLauncher.openURL(url.toString());
} catch (IOException e) {
XJAlert.display(parent, "Error", "Cannot display the feedback page because:\n" + e + "\n\nTo report a feedback, go to " + url + ".");
}
}
use of org.antlr.Tool in project antlrworks by antlr.
the class IDE method checkEnvironment.
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();
}
use of org.antlr.Tool in project antlrworks by antlr.
the class DecisionDFA method getDOTString.
@Override
public String getDOTString() throws Exception {
DecisionDFAEngine engine = window.decisionDFAEngine;
Grammar g;
int adjustedColumn = getDecisionColumn(g = engine.getDiscoveredParserGrammar());
if (adjustedColumn == -1)
adjustedColumn = getDecisionColumn(g = engine.getDiscoveredLexerGrammar());
if (adjustedColumn == -1)
throw new Exception("No decision in the current line");
CodeGenerator generator = new CodeGenerator(new Tool(), g, (String) g.getOption("language"));
DFA dfa = g.getLookaheadDFAFromPositionInFile(line, adjustedColumn);
decisionNumber = dfa.getDecisionNumber();
DOTGenerator dg = new DOTGenerator(g);
g.setCodeGenerator(generator);
dg.setArrowheadType("none");
// Left-to-right
dg.setRankdir("LR");
return dg.getDOT(dfa.startState);
}
use of org.antlr.Tool in project antlrworks by antlr.
the class CodeGenerate method generate.
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;
}
Aggregations