Search in sources :

Example 71 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.

the class PrologGeneratorTest method testCurrent1.

@Test
public void testCurrent1() throws Exception {
    final PrologTerm root = new CompoundPrologTerm("root");
    final PrologTerm stateid = new CompoundPrologTerm("stateid", root);
    final PrologTerm ap = new CompoundPrologTerm("ap", stateid);
    final PrologTerm implies = new CompoundPrologTerm("implies", ap, TERM_TRUE);
    final PrologTerm expected = new CompoundPrologTerm("globally", implies);
    check("G (current => true)", expected);
}
Also used : 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 72 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.

the class PrologGeneratorTest method testAction.

@Test
public void testAction() throws Exception {
    final PrologTerm transPred = new CompoundPrologTerm("bla");
    final PrologTerm wrapped = new CompoundPrologTerm("dtrans", transPred);
    final PrologTerm expected = new CompoundPrologTerm("action", wrapped);
    check("[bla]", expected);
}
Also used : 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 73 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.

the class Parserlib17Test method testParserlib17.

@Test
@Ignore
public void testParserlib17() throws Exception {
    // has to be ignored because the dummyparser can not parse the ap
    // might check for the syntax error exception instead?
    final PrologTerm none = new CompoundPrologTerm("none");
    final PrologTerm stringl = new CompoundPrologTerm("string", none, new CompoundPrologTerm("{"));
    final PrologTerm stringr = new CompoundPrologTerm("string", none, new CompoundPrologTerm("1"));
    final PrologTerm eq = new CompoundPrologTerm("equal", none, stringl, stringr);
    final PrologTerm bpred = new CompoundPrologTerm("bpred", eq);
    final PrologTerm ap = new CompoundPrologTerm("ap", bpred);
    final PrologTerm expected = new CompoundPrologTerm("globally", ap);
    check("G {\"{\"=\"1\"}", expected);
}
Also used : CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 74 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.

the class BindingGenerator method createBinding.

private static Map<String, PrologTerm> createBinding(final ListPrologTerm list) {
    Map<String, PrologTerm> result;
    result = new HashMap<String, PrologTerm>();
    for (int i = 0; i < list.size(); i++) {
        PrologTerm element = list.get(i);
        if (element.isTerm()) {
            CompoundPrologTerm binding = (CompoundPrologTerm) element;
            if (binding.getArity() == 2 && "=".equals(binding.getFunctor())) {
                extractBinding(result, binding);
            } else
                throw new IllegalArgumentException("Expected binding (=/2), but was " + binding.getFunctor() + "/" + String.valueOf(binding.getArity()));
        } else
            throw new IllegalArgumentException("Expected binding but was not a term");
    }
    return Collections.unmodifiableMap(result);
}
Also used : CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm)

Example 75 with CompoundPrologTerm

use of de.prob.prolog.term.CompoundPrologTerm in project probparsers by bendisposto.

the class BindingGenerator method extractBinding.

private static void extractBinding(final Map<String, PrologTerm> result, final CompoundPrologTerm binding) {
    PrologTerm varterm = binding.getArgument(1);
    if (varterm.isAtom()) {
        String name = ((CompoundPrologTerm) varterm).getFunctor();
        PrologTerm value = binding.getArgument(2);
        result.put(name, value);
    } else
        throw new IllegalArgumentException("Expected atomic variable name, but found " + varterm.toString());
}
Also used : CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm)

Aggregations

CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)90 PrologTerm (de.prob.prolog.term.PrologTerm)79 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)74 Test (org.junit.Test)62 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)8 StructuredPrologOutput (de.prob.prolog.output.StructuredPrologOutput)7 ClassicalB (de.prob.animator.domainobjects.ClassicalB)6 VariablePrologTerm (de.prob.prolog.term.VariablePrologTerm)6 EventB (de.prob.animator.domainobjects.EventB)5 Transition (de.prob.statespace.Transition)5 ArrayList (java.util.ArrayList)4 AbstractEvalResult (de.prob.animator.domainobjects.AbstractEvalResult)3 EvalResult (de.prob.animator.domainobjects.EvalResult)3 IEvalElement (de.prob.animator.domainobjects.IEvalElement)3 ISimplifiedROMap (de.prob.parser.ISimplifiedROMap)3 ComputationNotCompletedResult (de.prob.animator.domainobjects.ComputationNotCompletedResult)2 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)2 BigInteger (java.math.BigInteger)2 Collections (java.util.Collections)2 BParser (de.be4.classicalb.core.parser.BParser)1