use of de.prob.prolog.term.ListPrologTerm in project probparsers by bendisposto.
the class PrologGeneratorTest method testDLK2.
@Test
public void testDLK2() throws Exception {
final PrologTerm transPred1 = new CompoundPrologTerm("bla");
final PrologTerm wrapped1 = new CompoundPrologTerm("dtrans", transPred1);
final PrologTerm transPred2 = new CompoundPrologTerm("argg");
final PrologTerm wrapped2 = new CompoundPrologTerm("dtrans", transPred2);
final PrologTerm args = new ListPrologTerm(wrapped1, wrapped2);
final PrologTerm dlk = new CompoundPrologTerm("dlk", args);
final PrologTerm expected = new CompoundPrologTerm("ap", dlk);
check("deadlock(bla,argg)", expected);
}
use of de.prob.prolog.term.ListPrologTerm in project probparsers by bendisposto.
the class PrologGeneratorTest method testCtrl.
@Test
public void testCtrl() throws Exception {
final PrologTerm transPred1 = new CompoundPrologTerm("bla");
final PrologTerm wrapped1 = new CompoundPrologTerm("dtrans", transPred1);
final PrologTerm transPred2 = new CompoundPrologTerm("argg");
final PrologTerm wrapped2 = new CompoundPrologTerm("dtrans", transPred2);
final PrologTerm args = new ListPrologTerm(wrapped1, wrapped2);
final PrologTerm det = new CompoundPrologTerm("ctrl", args);
final PrologTerm expected = new CompoundPrologTerm("ap", det);
check("controller(bla,argg)", expected);
}
use of de.prob.prolog.term.ListPrologTerm in project probparsers by bendisposto.
the class PrologTermGenerator method toPrologTerm.
private static PrologTerm toPrologTerm(final PTerm node) {
PrologTerm term;
if (node instanceof ANumberTerm) {
String text = ((ANumberTerm) node).getNumber().getText();
term = new IntegerPrologTerm(new BigInteger(text));
} else if (node instanceof AAtomTerm) {
String text = ((AAtomTerm) node).getName().getText();
if ("[]".equals(text)) {
term = new ListPrologTerm(EMPTY_PROLOG_LIST);
} else {
text = removeQuotes(text);
term = new CompoundPrologTerm(text);
}
} else if (node instanceof ATerm) {
ATerm aterm = (ATerm) node;
int listSize = getListSize(node);
if (listSize >= 0) {
PrologTerm[] list = new PrologTerm[listSize];
fillListWithElements(list, aterm);
term = new ListPrologTerm(list);
} else {
String functor = removeQuotes(aterm.getFunctor().getText());
PrologTerm[] params = evalParameters((AParams) aterm.getParams());
term = new CompoundPrologTerm(functor, params);
}
} else if (node instanceof AVariableTerm) {
String text = removeQuotes(((AVariableTerm) node).getVariable().getText());
term = new VariablePrologTerm(text);
} else
throw new IllegalStateException("Unexpected subclass of PTerm: " + node.getClass().getCanonicalName());
return term;
}
use of de.prob.prolog.term.ListPrologTerm in project probparsers by bendisposto.
the class FastReadTransformer method fastwrite.
private void fastwrite(PrologTerm term) {
if (term instanceof IntegerPrologTerm) {
IntegerPrologTerm intTerm = (IntegerPrologTerm) term;
write(intTerm);
}
if (term instanceof CompoundPrologTerm) {
write(term);
}
if (term instanceof VariablePrologTerm) {
write((VariablePrologTerm) term);
}
if (term instanceof ListPrologTerm) {
ListPrologTerm list = (ListPrologTerm) term;
write(list);
}
}
use of de.prob.prolog.term.ListPrologTerm in project prob2 by bendisposto.
the class ComputeCoverageCommand method processResult.
@Override
public void processResult(final ISimplifiedROMap<String, PrologTerm> bindings) {
IntegerPrologTerm totalNodeNr = (IntegerPrologTerm) bindings.get("TotalNodeNr");
IntegerPrologTerm totalTransNr = (IntegerPrologTerm) bindings.get("TotalTransSum");
ListPrologTerm ops = BindingGenerator.getList(bindings.get("OpStat"));
ListPrologTerm nodes = BindingGenerator.getList(bindings.get("NodeStat"));
ListPrologTerm uncovered = BindingGenerator.getList(bindings.get("Uncovered"));
coverageResult = new ComputeCoverageResult(totalNodeNr, totalTransNr, ops, nodes, uncovered);
}
Aggregations