Search in sources :

Example 76 with PrologTerm

use of de.prob.prolog.term.PrologTerm 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 77 with PrologTerm

use of de.prob.prolog.term.PrologTerm 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 78 with PrologTerm

use of de.prob.prolog.term.PrologTerm 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 79 with PrologTerm

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

the class JoinedParserBase method parse.

private void parse(final Type type, final IPrologTermOutput pto, final String formula, final boolean wrap) throws ProBParseException {
    ProBParseException parseException = null;
    UnsupportedOperationException unsupportedException = null;
    for (final ProBParserBaseAdapter parser : parsers) {
        try {
            final PrologTerm term;
            switch(type) {
                case EXPR:
                    term = parser.parseExpression(formula, wrap);
                    break;
                case PRED:
                    term = parser.parsePredicate(formula, wrap);
                    break;
                case TRANS:
                    term = parser.parseTransitionPredicate(formula, wrap);
                    break;
                default:
                    throw new IllegalStateException();
            }
            pto.printTerm(term);
            return;
        } catch (ProBParseException e) {
            if (parseException == null) {
                parseException = e;
            }
        } catch (UnsupportedOperationException e) {
            if (unsupportedException == e) {
                unsupportedException = e;
            }
        }
    }
    if (parseException != null)
        throw parseException;
    else
        throw unsupportedException;
}
Also used : PrologTerm(de.prob.prolog.term.PrologTerm)

Example 80 with PrologTerm

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

the class StructuredPrologOutput method closeList.

public IPrologTermOutput closeList() {
    PrologTerm[] elements = getArguments();
    popFromStack();
    addArgument(new ListPrologTerm(elements));
    return this;
}
Also used : ListPrologTerm(de.prob.prolog.term.ListPrologTerm) 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

PrologTerm (de.prob.prolog.term.PrologTerm)103 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)86 CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)85 Test (org.junit.Test)64 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)11 StructuredPrologOutput (de.prob.prolog.output.StructuredPrologOutput)10 VariablePrologTerm (de.prob.prolog.term.VariablePrologTerm)8 Transition (de.prob.statespace.Transition)5 IEvalElement (de.prob.animator.domainobjects.IEvalElement)4 ArrayList (java.util.ArrayList)4 CheckBooleanPropertyCommand (de.prob.animator.command.CheckBooleanPropertyCommand)3 AbstractEvalResult (de.prob.animator.domainobjects.AbstractEvalResult)3 EvalResult (de.prob.animator.domainobjects.EvalResult)3 ISimplifiedROMap (de.prob.parser.ISimplifiedROMap)3 IPrologTermOutput (de.prob.prolog.output.IPrologTermOutput)3 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)2 LtlParseException (de.be4.ltl.core.parser.LtlParseException)2 ClassicalB (de.prob.animator.domainobjects.ClassicalB)2 ComputationNotCompletedResult (de.prob.animator.domainobjects.ComputationNotCompletedResult)2 StateError (de.prob.animator.domainobjects.StateError)2