Search in sources :

Example 1 with ASTDisplay

use of de.be4.eventb.core.parser.analysis.ASTDisplay in project probparsers by bendisposto.

the class BParser method fullParsing.

public int fullParsing(final File bfile, final ParsingBehaviour parsingBehaviour, final PrintStream out, final PrintStream err) {
    try {
        // Properties hashes = new Properties();
        // if (parsingBehaviour.getOutputFile() != null) {
        // if (hashesStillValid(parsingBehaviour.getOutputFile())){
        // return 0;
        // }
        // }
        final long start = System.currentTimeMillis();
        final Start tree = parseFile(bfile, parsingBehaviour.isVerbose());
        final long end = System.currentTimeMillis();
        if (parsingBehaviour.isPrintTime()) {
            out.println("Time for parsing: " + (end - start) + "ms");
        }
        if (parsingBehaviour.isPrintAST()) {
            ASTPrinter sw = new ASTPrinter(out);
            tree.apply(sw);
        }
        if (parsingBehaviour.isDisplayGraphically()) {
            tree.apply(new ASTDisplay());
        }
        final long start2 = System.currentTimeMillis();
        if (parsingBehaviour.isPrologOutput()) {
            printASTasProlog(out, this, bfile, tree, parsingBehaviour, contentProvider);
        }
        final long end2 = System.currentTimeMillis();
        if (parsingBehaviour.isPrintTime()) {
            out.println("Time for Prolog output: " + (end2 - start2) + "ms");
        }
        if (parsingBehaviour.isFastPrologOutput()) {
            try {
                String fp = getASTasFastProlog(this, bfile, tree, parsingBehaviour, contentProvider);
                out.println(fp);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
    } catch (final IOException e) {
        if (parsingBehaviour.isPrologOutput()) {
            PrologExceptionPrinter.printException(err, e, bfile.getAbsolutePath());
        } else {
            err.println();
            err.println("Error reading input file: " + e.getLocalizedMessage());
        }
        return -2;
    } catch (final BCompoundException e) {
        if (parsingBehaviour.isPrologOutput()) {
            PrologExceptionPrinter.printException(err, e, parsingBehaviour.isUseIndention(), false);
        // PrologExceptionPrinter.printException(err, e);
        } else {
            err.println();
            err.println("Error parsing input file: " + e.getLocalizedMessage());
        }
        return -3;
    }
    return 0;
}
Also used : Start(de.be4.classicalb.core.parser.node.Start) ASTPrinter(de.be4.classicalb.core.parser.visualisation.ASTPrinter) ASTDisplay(de.be4.classicalb.core.parser.visualisation.ASTDisplay) IOException(java.io.IOException) LexerException(de.be4.classicalb.core.parser.lexer.LexerException) IOException(java.io.IOException) ParserException(de.be4.classicalb.core.parser.parser.ParserException)

Example 2 with ASTDisplay

use of de.be4.eventb.core.parser.analysis.ASTDisplay in project probparsers by bendisposto.

the class EventBParser method main.

public static void main(final String[] args) {
    if (args.length < 1) {
        System.err.println("usage: BParser [options] <BMachine file>");
        System.err.println();
        System.err.println("Available options are:");
        System.err.println(CLI_SWITCH_VERBOSE + "\t\tVerbose output during lexing and parsing");
        System.err.println(CLI_SWITCH_TIME + "\t\tOutput time used for complete parsing process.");
        System.err.println(CLI_SWITCH_AST + "\t\tPrint AST on standard output.");
        System.err.println(CLI_SWITCH_UI + "\t\tShow AST as Swing UI.");
        System.exit(-1);
    }
    try {
        final long start = System.currentTimeMillis();
        final EventBParser parser = new EventBParser();
        final Start tree = parser.parseFile(new File(args[args.length - 1]), isCliSwitchSet(args, CLI_SWITCH_VERBOSE));
        final long end = System.currentTimeMillis();
        System.out.println();
        if (isCliSwitchSet(args, CLI_SWITCH_TIME)) {
            System.out.println("Time for parsing: " + (end - start) + "ms");
        }
        if (isCliSwitchSet(args, CLI_SWITCH_AST)) {
            System.out.println("AST:");
            tree.apply(new ASTPrinter());
        }
        if (isCliSwitchSet(args, CLI_SWITCH_UI)) {
            tree.apply(new ASTDisplay());
        }
    } catch (final IOException e) {
        System.err.println();
        System.err.println("Error reading input file: " + e.getLocalizedMessage());
        System.exit(-2);
    } catch (final BException e) {
        System.err.println();
        System.err.println("Error parsing input file: " + e.getLocalizedMessage());
        System.exit(-3);
    }
}
Also used : Start(de.be4.eventbalg.core.parser.node.Start) ASTPrinter(de.be4.eventbalg.core.parser.analysis.ASTPrinter) ASTDisplay(de.be4.eventbalg.core.parser.analysis.ASTDisplay) IOException(java.io.IOException) File(java.io.File)

Example 3 with ASTDisplay

use of de.be4.eventb.core.parser.analysis.ASTDisplay in project probparsers by bendisposto.

the class EventBParser method main.

public static void main(final String[] args) {
    if (args.length < 1) {
        System.err.println("usage: BParser [options] <BMachine file>");
        System.err.println();
        System.err.println("Available options are:");
        System.err.println(CLI_SWITCH_VERBOSE + "\t\tVerbose output during lexing and parsing");
        System.err.println(CLI_SWITCH_TIME + "\t\tOutput time used for complete parsing process.");
        System.err.println(CLI_SWITCH_AST + "\t\tPrint AST on standard output.");
        System.err.println(CLI_SWITCH_UI + "\t\tShow AST as Swing UI.");
        System.exit(-1);
    }
    try {
        final long start = System.currentTimeMillis();
        final EventBParser parser = new EventBParser();
        final Start tree = parser.parseFile(new File(args[args.length - 1]), isCliSwitchSet(args, CLI_SWITCH_VERBOSE));
        final long end = System.currentTimeMillis();
        System.out.println();
        if (isCliSwitchSet(args, CLI_SWITCH_TIME)) {
            System.out.println("Time for parsing: " + (end - start) + "ms");
        }
        if (isCliSwitchSet(args, CLI_SWITCH_AST)) {
            System.out.println("AST:");
            tree.apply(new ASTPrinter());
        }
        if (isCliSwitchSet(args, CLI_SWITCH_UI)) {
            tree.apply(new ASTDisplay());
        }
    } catch (final IOException e) {
        System.err.println();
        System.err.println("Error reading input file: " + e.getLocalizedMessage());
        System.exit(-2);
    } catch (final BException e) {
        System.err.println();
        System.err.println("Error parsing input file: " + e.getLocalizedMessage());
        System.exit(-3);
    }
}
Also used : Start(de.be4.eventb.core.parser.node.Start) ASTPrinter(de.be4.eventb.core.parser.analysis.ASTPrinter) ASTDisplay(de.be4.eventb.core.parser.analysis.ASTDisplay) IOException(java.io.IOException) File(java.io.File)

Aggregations

IOException (java.io.IOException)3 File (java.io.File)2 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)1 Start (de.be4.classicalb.core.parser.node.Start)1 ParserException (de.be4.classicalb.core.parser.parser.ParserException)1 ASTDisplay (de.be4.classicalb.core.parser.visualisation.ASTDisplay)1 ASTPrinter (de.be4.classicalb.core.parser.visualisation.ASTPrinter)1 ASTDisplay (de.be4.eventb.core.parser.analysis.ASTDisplay)1 ASTPrinter (de.be4.eventb.core.parser.analysis.ASTPrinter)1 Start (de.be4.eventb.core.parser.node.Start)1 ASTDisplay (de.be4.eventbalg.core.parser.analysis.ASTDisplay)1 ASTPrinter (de.be4.eventbalg.core.parser.analysis.ASTPrinter)1 Start (de.be4.eventbalg.core.parser.node.Start)1