Search in sources :

Example 11 with PrologTermOutput

use of de.prob.prolog.output.PrologTermOutput in project probparsers by bendisposto.

the class UnitPragmaTest method printAST.

private String printAST(final Node node) {
    final StringWriter swriter = new StringWriter();
    NodeIdAssignment nodeids = new NodeIdAssignment();
    node.apply(nodeids);
    IPrologTermOutput pout = new PrologTermOutput(new PrintWriter(swriter), false);
    PositionPrinter pprinter = new ClassicalPositionPrinter(nodeids);
    ASTProlog prolog = new ASTProlog(pout, pprinter);
    node.apply(prolog);
    swriter.flush();
    return swriter.toString();
}
Also used : ClassicalPositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter) ASTProlog(de.be4.classicalb.core.parser.analysis.prolog.ASTProlog) StringWriter(java.io.StringWriter) PrologTermOutput(de.prob.prolog.output.PrologTermOutput) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) PositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.PositionPrinter) ClassicalPositionPrinter(de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter) NodeIdAssignment(de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) PrintWriter(java.io.PrintWriter)

Example 12 with PrologTermOutput

use of de.prob.prolog.output.PrologTermOutput in project probparsers by bendisposto.

the class CreateFreetypeTest method main.

public static void main(String[] args) throws IOException {
    final String filename = "freetypetest.prob";
    CreateFreetypeTest test = new CreateFreetypeTest();
    final OutputStream file = new FileOutputStream(filename);
    final PrologTermOutput pto = new PrologTermOutput(file);
    // parser_version(none).
    pto.openTerm("parser_version");
    pto.printAtom("none");
    pto.closeTerm();
    pto.fullstop();
    // classical_b(machine_name, [filename])
    pto.openTerm("classical_b");
    pto.printAtom(MACHINE_NAME);
    pto.openList();
    pto.printAtom(filename);
    pto.closeList();
    pto.closeTerm();
    pto.fullstop();
    // machine(...)
    pto.openTerm("machine");
    test.printProlog(pto);
    pto.closeTerm();
    pto.fullstop();
    pto.flush();
    file.close();
}
Also used : PrologTermOutput(de.prob.prolog.output.PrologTermOutput) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) FileOutputStream(java.io.FileOutputStream)

Example 13 with PrologTermOutput

use of de.prob.prolog.output.PrologTermOutput in project probparsers by bendisposto.

the class PrologExceptionPrinter method printException.

public static void printException(final OutputStream out, final IOException e, final String filename, boolean useIndentation, boolean lineOneOff) {
    IPrologTermOutput pto = new PrologTermOutput(out, useIndentation);
    pto.openTerm("io_exception");
    printMsg(pto, e, filename, useIndentation, lineOneOff, false);
    pto.closeTerm();
    pto.fullstop();
    pto.flush();
}
Also used : PrologTermOutput(de.prob.prolog.output.PrologTermOutput) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput)

Example 14 with PrologTermOutput

use of de.prob.prolog.output.PrologTermOutput in project probparsers by bendisposto.

the class RecursiveMachineLoader method printAsProlog.

public void printAsProlog(final PrintWriter out) {
    final IPrologTermOutput pout = new PrologTermOutput(out, parsingBehaviour.isUseIndention());
    printAsProlog(pout);
}
Also used : PrologTermOutput(de.prob.prolog.output.PrologTermOutput) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput) IPrologTermOutput(de.prob.prolog.output.IPrologTermOutput)

Aggregations

PrologTermOutput (de.prob.prolog.output.PrologTermOutput)14 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)13 PrintWriter (java.io.PrintWriter)7 NodeIdAssignment (de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment)5 StringWriter (java.io.StringWriter)5 ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)4 ClassicalPositionPrinter (de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter)4 PositionPrinter (de.be4.classicalb.core.parser.analysis.prolog.PositionPrinter)4 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)3 FileOutputStream (java.io.FileOutputStream)3 OutputStream (java.io.OutputStream)3 IOException (java.io.IOException)2 BParser (de.be4.classicalb.core.parser.BParser)1 BException (de.be4.classicalb.core.parser.exceptions.BException)1 BLexerException (de.be4.classicalb.core.parser.exceptions.BLexerException)1 BParseException (de.be4.classicalb.core.parser.exceptions.BParseException)1 CheckException (de.be4.classicalb.core.parser.exceptions.CheckException)1 PreParseException (de.be4.classicalb.core.parser.exceptions.PreParseException)1 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)1 AConstructorFreetypeConstructor (de.be4.classicalb.core.parser.node.AConstructorFreetypeConstructor)1