Search in sources :

Example 1 with ABSFormatter

use of org.abs_models.backend.prettyprint.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 DefaultABSFormatter(w);
    m2.doPrettyPrint(w, f);
    return writer.toString();
}
Also used : DefaultABSFormatter(org.abs_models.backend.prettyprint.DefaultABSFormatter) StringWriter(java.io.StringWriter) ABSFormatter(org.abs_models.backend.prettyprint.ABSFormatter) DefaultABSFormatter(org.abs_models.backend.prettyprint.DefaultABSFormatter) PrintWriter(java.io.PrintWriter)

Example 2 with ABSFormatter

use of org.abs_models.backend.prettyprint.ABSFormatter in project abstools by abstools.

the class ASTBasedABSTestRunnerGenerator method generateTestRunner.

@Override
public void generateTestRunner(PrintStream stream) {
    // In order to safely call module.doPrettyPrint() we need a complete AST
    Model model = new Model();
    CompilationUnit compilationunit = new CompilationUnit();
    ModuleDecl module = new ModuleDecl();
    model.addCompilationUnitNoTransform(compilationunit);
    compilationunit.addModuleDeclNoTransform(module);
    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);
}
Also used : CompilationUnit(org.abs_models.frontend.ast.CompilationUnit) DefaultABSFormatter(org.abs_models.backend.prettyprint.DefaultABSFormatter) ABSFormatter(org.abs_models.backend.prettyprint.ABSFormatter) DefaultABSFormatter(org.abs_models.backend.prettyprint.DefaultABSFormatter) Model(org.abs_models.frontend.ast.Model) ModuleDecl(org.abs_models.frontend.ast.ModuleDecl) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)2 ABSFormatter (org.abs_models.backend.prettyprint.ABSFormatter)2 DefaultABSFormatter (org.abs_models.backend.prettyprint.DefaultABSFormatter)2 StringWriter (java.io.StringWriter)1 CompilationUnit (org.abs_models.frontend.ast.CompilationUnit)1 Model (org.abs_models.frontend.ast.Model)1 ModuleDecl (org.abs_models.frontend.ast.ModuleDecl)1