Package org.antlr.works.utils

Examples of org.antlr.works.utils.StreamWatcher


            return classPath;
    }

    public static String runANTLR(Console console, String file, String libPath, String outputPath, StreamWatcherDelegate delegate) {
        String error = null;
        StreamWatcher esw = null;
        int result = 0;
        try {
            String[] args = new String[9];
            args[0] = "java";
            args[1] = "-cp";
            args[2] = getClassPath(outputPath);
            args[3] = "org.antlr.Tool";
            args[4] = "-o";
            args[5] = Utils.quotePath(outputPath);
            args[6] = "-lib";
            args[7] = Utils.quotePath(libPath);
            args[8] = file;

            IDE.debugVerbose(console, DebuggerEngine.class, "Run ANTLR: "+Utils.toString(args));

            Process p = Runtime.getRuntime().exec(args);
            setProcess(p);
            esw = new StreamWatcher(p.getErrorStream(), "ANTLR[error]", delegate);
            esw.start();
            new StreamWatcher(p.getInputStream(), "ANTLR[stdout]", delegate).start();
            result = p.waitFor();
        } catch(Exception e) {
            error = "Failed to run ANTLR with exception:\n"+e.toString();
        } finally {
            removeProcess();
        }

        if(result != 0) {
            error = "Failed to run ANTLR with result:\n"+result;
        }

        /** Make sure ANTLR didn't return an error in the error string
         *
         */

        if(error == null) {
            for (String line : esw.getLines()) {
                if (line.startsWith("ANTLR Parser Generator"))
                    continue;

                if (line.startsWith("no such locale file"))
                    continue;
View Full Code Here


            IDE.debugVerbose(console, DebuggerEngine.class, "Run Java: "+Utils.toString(args));

            Process p = Runtime.getRuntime().exec(args, null, new File(currentPath));
            setProcess(p);
            new StreamWatcher(p.getErrorStream(), "Java[error]", delegate).start();
            new StreamWatcher(p.getInputStream(), "Java[stdout]", delegate).start();
            result = p.waitFor();
        } catch(Exception e) {
            error = "Failed to run Java with exception:\n"+e.toString();
        } finally {
            removeProcess();
View Full Code Here

                IDE.debugVerbose(console, DebuggerEngine.class, "Compile: "+Utils.toString(args));

                Process p = Runtime.getRuntime().exec(args);
                setProcess(p);
                new StreamWatcher(p.getErrorStream(), "Compiler[error]", delegate).start();
                new StreamWatcher(p.getInputStream(), "Compiler[stdout]", delegate).start();
                result = p.waitFor();
            } else if(compiler.equalsIgnoreCase(AWPrefs.COMPILER_JIKES)) {
                String jikesPath = XJUtils.concatPath(AWPrefs.getJikesPath(), "jikes");

                String[] args = new String[5+files.length];
                args[0] = jikesPath;
                args[1] = "-classpath";
                args[2] = classPath;
                args[3] = "-d";
                args[4] = Utils.quotePath(outputFileDir);
                System.arraycopy(files, 0, args, 5, files.length);

                IDE.debugVerbose(console, DebuggerEngine.class, "Compile: "+Utils.toString(args));

                Process p = Runtime.getRuntime().exec(args);
                setProcess(p);
                new StreamWatcher(p.getErrorStream(), "Compiler[error]", delegate).start();
                new StreamWatcher(p.getInputStream(), "Compiler[stdout]", delegate).start();
                result = p.waitFor();
            } else if(compiler.equalsIgnoreCase(AWPrefs.COMPILER_INTEGRATED)) {
                String[] args = new String[2+files.length];
                args[0] = "-d";
                args[1] = outputFileDir;
View Full Code Here

TOP

Related Classes of org.antlr.works.utils.StreamWatcher

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.