use of de.be4.classicalb.core.parser.analysis.prolog.PositionPrinter in project probparsers by bendisposto.
the class ASTPrologTest 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();
System.out.println(swriter.toString());
return swriter.toString();
}
use of de.be4.classicalb.core.parser.analysis.prolog.PositionPrinter in project probparsers by bendisposto.
the class ASTPrologTest method testFreeType.
@Test
public void testFreeType() throws BCompoundException {
final AConstructorFreetypeConstructor multi = new AConstructorFreetypeConstructor(new TIdentifierLiteral("multi"), new APowSubsetExpression(new AIntegerSetExpression()));
final AConstructorFreetypeConstructor single = new AConstructorFreetypeConstructor(new TIdentifierLiteral("single"), new AIntegerSetExpression());
final AFreetype freetype = new AFreetype(new TIdentifierLiteral("T"), Arrays.<PFreetypeConstructor>asList(multi, single));
AFreetypesMachineClause clause = new AFreetypesMachineClause(Arrays.<PFreetype>asList(freetype));
final StringWriter swriter = new StringWriter();
NodeIdAssignment nodeids = new NodeIdAssignment();
clause.apply(nodeids);
IPrologTermOutput pout = new PrologTermOutput(new PrintWriter(swriter), false);
PositionPrinter pprinter = new ClassicalPositionPrinter(nodeids);
ASTProlog prolog = new ASTProlog(pout, pprinter);
clause.apply(prolog);
String code = swriter.toString();
assertFalse(code.isEmpty());
assertEquals("freetypes(0,[freetype(1,'T',[constructor(2,multi,pow_subset(3,integer_set(4))),constructor(5,single,integer_set(6))])])", code);
}
use of de.be4.classicalb.core.parser.analysis.prolog.PositionPrinter in project probparsers by bendisposto.
the class PragmaTest 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();
}
use of de.be4.classicalb.core.parser.analysis.prolog.PositionPrinter 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();
}
Aggregations