use of de.be4.classicalb.core.parser.node.AFreetype 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.node.AFreetype in project probparsers by bendisposto.
the class CreateFreetypeTest method createFreetype.
private AFreetypesMachineClause createFreetype() {
final AConstructorFreetypeConstructor cons1 = new AConstructorFreetypeConstructor(new TIdentifierLiteral(CONS_BOOL), new ABoolSetExpression());
final AConstructorFreetypeConstructor cons2 = new AConstructorFreetypeConstructor(new TIdentifierLiteral(CONS_INT), new AIntSetExpression());
final AElementFreetypeConstructor cons3 = new AElementFreetypeConstructor(new TIdentifierLiteral(CONS_EMPTY));
final AFreetype freetype = new AFreetype(new TIdentifierLiteral(FREETYPE_NAME), Arrays.<PFreetypeConstructor>asList(cons1, cons2, cons3));
return new AFreetypesMachineClause(Arrays.<PFreetype>asList(freetype));
}
Aggregations