Search in sources :

Example 1 with Tool

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 + ".");
    }
}
Also used : IOException(java.io.IOException) Tool(org.antlr.Tool)

Example 2 with Tool

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();
}
Also used : PrintStream(java.io.PrintStream) Tool(org.antlr.Tool)

Example 3 with Tool

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);
}
Also used : DOTGenerator(org.antlr.tool.DOTGenerator) Grammar(org.antlr.tool.Grammar) CodeGenerator(org.antlr.codegen.CodeGenerator) DFA(org.antlr.analysis.DFA) Tool(org.antlr.Tool)

Example 4 with Tool

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;
}
Also used : ErrorListener(org.antlr.works.utils.ErrorListener) File(java.io.File) Tool(org.antlr.Tool)

Aggregations

Tool (org.antlr.Tool)4 File (java.io.File)1 IOException (java.io.IOException)1 PrintStream (java.io.PrintStream)1 DFA (org.antlr.analysis.DFA)1 CodeGenerator (org.antlr.codegen.CodeGenerator)1 DOTGenerator (org.antlr.tool.DOTGenerator)1 Grammar (org.antlr.tool.Grammar)1 ErrorListener (org.antlr.works.utils.ErrorListener)1