use of de.prob.animator.prologast.ASTFormula in project prob2 by bendisposto.
the class GetMachineStructureCommand method makeASTNode.
private static PrologASTNode makeASTNode(PrologTerm node) {
if ("formula".equals(node.getFunctor())) {
final PrologTerm term = node.getArgument(1);
final PrologTerm prettyPrintTerm = node.getArgument(2);
// It's not clear if this is the intended behavior, or if they should have been converted to atoms in the Prolog code.
if (!prettyPrintTerm.isAtom() && !prettyPrintTerm.isNumber()) {
throw new IllegalArgumentException("Formula pretty print must be an atom or number: " + prettyPrintTerm);
}
final String prettyPrint = prettyPrintTerm.getFunctor();
return new ASTFormula(term, prettyPrint);
} else if ("category".equals(node.getFunctor())) {
final String name = node.getArgument(1).getFunctor();
final List<String> infos = PrologTerm.atomicStrings((ListPrologTerm) node.getArgument(2));
final List<PrologASTNode> subnodes = buildAST(BindingGenerator.getList(node.getArgument(3)));
final boolean expanded = infos.contains("expanded");
final boolean propagated = infos.contains("propagated");
return new ASTCategory(subnodes, name, expanded, propagated);
} else {
throw new AssertionError("Unknown node type: " + node.getFunctor());
}
}
Aggregations