use of de.be4.eventb.core.parser.analysis.ASTPrinter 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;
}
use of de.be4.eventb.core.parser.analysis.ASTPrinter in project probparsers by bendisposto.
the class SubstitutionTest method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException {
// System.out.println("Parsing \"" + testMachine + "\"");
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, false);
// startNode.apply(new ASTPrinter());
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
final String string = ast2String.toString();
// System.out.println(string);
return string;
}
use of de.be4.eventb.core.parser.analysis.ASTPrinter in project probparsers by bendisposto.
the class Helpers method getTreeAsString.
public static String getTreeAsString(final String testMachine) throws BCompoundException {
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, false);
// startNode.apply(new ASTPrinter());
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
final String string = ast2String.toString();
// System.out.println(string);
return string;
}
use of de.be4.eventb.core.parser.analysis.ASTPrinter in project probparsers by bendisposto.
the class StructuralTest method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException {
// System.out.println("Parsing: \"" + testMachine + "\":");
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, false);
// startNode.apply(new ASTPrinter());
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
final String string = ast2String.toString();
// System.out.println();
return string;
}
use of de.be4.eventb.core.parser.analysis.ASTPrinter in project probparsers by bendisposto.
the class SyntaxErrorsDetectedOnTokenStreamTest method getTreeAsString.
private String getTreeAsString(final String testMachine) throws BCompoundException {
// System.out.println("Parsing: \"" + testMachine + "\":");
final BParser parser = new BParser("testcase");
final Start startNode = parser.parse(testMachine, false);
// startNode.apply(new ASTPrinter());
final Ast2String ast2String = new Ast2String();
startNode.apply(ast2String);
final String string = ast2String.toString();
// System.out.println();
return string;
}
Aggregations