use of abs.frontend.tests.ABSFormatter in project abstools by abstools.
the class PrettyPrinterBackEnd method compile.
/**
* @param args
* @throws Exception
*/
public int compile(String[] args) throws Exception {
final Model model = parseFiles(parseArgs(args).toArray(new String[0]));
if (keepsugar) {
model.doAACrewrite = false;
model.doForEachRewrite = false;
}
analyzeFlattenAndRewriteModel(model);
if (!force && (model.hasParserErrors() || model.hasErrors() || model.hasTypeErrors())) {
printErrorMessage();
return 1;
}
final PrintStream stream;
final String loc;
if (outputfile != null) {
stream = new PrintStream(outputfile);
loc = outputfile.getAbsolutePath();
} else {
stream = System.out;
loc = "Standard Output Stream";
}
if (verbose) {
System.out.println("Output ABS model source code to " + loc + "...");
}
PrintWriter writer = new PrintWriter(stream, true);
ABSFormatter formatter = new DefaultABSFormatter(writer);
model.doPrettyPrint(writer, formatter);
return 0;
}
use of abs.frontend.tests.ABSFormatter in project abstools by abstools.
the class OtherAnalysisTests method prettyPrint.
public static String prettyPrint(Model m2) {
StringWriter writer = new StringWriter();
PrintWriter w = new PrintWriter(writer);
ABSFormatter f = new EmptyFormatter();
m2.doPrettyPrint(w, f);
return writer.toString();
}
use of abs.frontend.tests.ABSFormatter in project abstools by abstools.
the class PrettyPrinterTests method prettyPrint.
private String prettyPrint(ASTNode<?> d) {
StringWriter writer = new StringWriter();
PrintWriter w = new PrintWriter(writer);
ABSFormatter f = new EmptyFormatter();
d.doPrettyPrint(w, f);
return writer.toString();
}
use of abs.frontend.tests.ABSFormatter in project abstools by abstools.
the class ABSUnitTestCaseTranslator method printToFile.
@SuppressWarnings("rawtypes")
private void printToFile(List<ASTNode<ASTNode>> nodes, File file) {
try {
PrintStream stream = new PrintStream(file);
PrintWriter writer = new PrintWriter(stream, true);
ABSFormatter formatter = new DefaultABSFormatter(writer);
for (ASTNode<ASTNode> n : nodes) {
n.doPrettyPrint(writer, formatter);
}
} catch (FileNotFoundException e) {
e.printStackTrace(new PrintStream(ConsoleHandler.getDefault().newMessageStream()));
}
}
use of abs.frontend.tests.ABSFormatter in project abstools by abstools.
the class ASTBasedABSTestRunnerGenerator method generateTestRunner.
@Override
public void generateTestRunner(PrintStream stream) {
ModuleDecl module = new ModuleDecl();
module.setName(RUNNER_MAIN);
module.setImportList(generateImportsAST());
module.setBlock(generateMainBlockAST(module.getImportList()));
PrintWriter writer = new PrintWriter(stream, true);
ABSFormatter formatter = new DefaultABSFormatter(writer);
module.doPrettyPrint(writer, formatter);
}
Aggregations