Search in sources :

Example 1 with ListPrologTerm

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);
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 2 with ListPrologTerm

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);
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Test(org.junit.Test)

Example 3 with ListPrologTerm

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;
}
Also used : VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm) AAtomTerm(de.prob.core.sablecc.node.AAtomTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) ANumberTerm(de.prob.core.sablecc.node.ANumberTerm) ATerm(de.prob.core.sablecc.node.ATerm) BigInteger(java.math.BigInteger) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm) AVariableTerm(de.prob.core.sablecc.node.AVariableTerm)

Example 4 with ListPrologTerm

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);
    }
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm)

Example 5 with ListPrologTerm

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);
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm)

Aggregations

ListPrologTerm (de.prob.prolog.term.ListPrologTerm)38 PrologTerm (de.prob.prolog.term.PrologTerm)33 CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)27 Test (org.junit.Test)11 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)6 VariablePrologTerm (de.prob.prolog.term.VariablePrologTerm)4 ArrayList (java.util.ArrayList)4 Transition (de.prob.statespace.Transition)3 AbstractEvalResult (de.prob.animator.domainobjects.AbstractEvalResult)2 ComputationNotCompletedResult (de.prob.animator.domainobjects.ComputationNotCompletedResult)2 EvalResult (de.prob.animator.domainobjects.EvalResult)2 IEvalElement (de.prob.animator.domainobjects.IEvalElement)2 StateError (de.prob.animator.domainobjects.StateError)2 HashMap (java.util.HashMap)2 List (java.util.List)2 DotEdge (de.prob.animator.domainobjects.DotEdge)1 DotNode (de.prob.animator.domainobjects.DotNode)1 ProBPreference (de.prob.animator.domainobjects.ProBPreference)1 ASTCategory (de.prob.animator.prologast.ASTCategory)1 ASTFormula (de.prob.animator.prologast.ASTFormula)1