Search in sources :

Example 1 with StructuredPrologOutput

use of de.prob.prolog.output.StructuredPrologOutput in project probparsers by bendisposto.

the class TemporalLogicParser method generatePrologTerm.

public PrologTerm generatePrologTerm(final String formula, final String stateID) throws LtlParseException {
    T ast;
    try {
        ast = parseFormula(formula);
    } catch (IOException e) {
        String msg = "StringReader should not cause IOExceptions";
        throw new IllegalStateException(msg);
    }
    StructuredPrologOutput pto = new StructuredPrologOutput();
    try {
        applyPrologGenerator(pto, stateID, specParser, ast);
    } catch (LtlAdapterException e) {
        throw e.getOriginalException();
    }
    pto.fullstop();
    return pto.getSentences().iterator().next();
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput) LtlAdapterException(de.be4.ltl.core.parser.internal.LtlAdapterException) IOException(java.io.IOException)

Example 2 with StructuredPrologOutput

use of de.prob.prolog.output.StructuredPrologOutput in project probparsers by bendisposto.

the class ProBParserBaseAdapter method parsePredicate.

public PrologTerm parsePredicate(final String predicate, final boolean wrap) throws ProBParseException, UnsupportedOperationException {
    final StructuredPrologOutput pto = new StructuredPrologOutput();
    base.parsePredicate(pto, predicate, wrap);
    return getSingleTerm(pto);
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput)

Example 3 with StructuredPrologOutput

use of de.prob.prolog.output.StructuredPrologOutput in project probparsers by bendisposto.

the class ProBParserBaseAdapter method parseExpression.

public PrologTerm parseExpression(final String expression, final boolean wrap) throws ProBParseException, UnsupportedOperationException {
    final StructuredPrologOutput pto = new StructuredPrologOutput();
    base.parseExpression(pto, expression, wrap);
    return getSingleTerm(pto);
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput)

Example 4 with StructuredPrologOutput

use of de.prob.prolog.output.StructuredPrologOutput in project prob2 by bendisposto.

the class LoadRulesProjectCommand method printLoadTerm.

private void printLoadTerm(IPrologTermOutput pto) {
    StructuredPrologOutput parserOutput = new StructuredPrologOutput();
    this.project.printProjectAsPrologTerm(parserOutput);
    for (PrologTerm term : parserOutput.getSentences()) {
        pto.printTerm(term);
    }
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput) PrologTerm(de.prob.prolog.term.PrologTerm)

Example 5 with StructuredPrologOutput

use of de.prob.prolog.output.StructuredPrologOutput in project prob2 by bendisposto.

the class GetStateBasedErrorsCommandTest method testWriteCommand.

@Test
public void testWriteCommand() {
    StructuredPrologOutput prologTermOutput = new StructuredPrologOutput();
    GetStateBasedErrorsCommand command = new GetStateBasedErrorsCommand("42");
    command.writeCommand(prologTermOutput);
    prologTermOutput.fullstop().flush();
    Collection<PrologTerm> sentences = prologTermOutput.getSentences();
    PrologTerm next = sentences.iterator().next();
    assertNotNull(next);
    assertTrue(next instanceof CompoundPrologTerm);
    CompoundPrologTerm t = (CompoundPrologTerm) next;
    assertEquals("get_state_errors", t.getFunctor());
    assertEquals(2, t.getArity());
    PrologTerm argument = t.getArgument(1);
    assertTrue(argument.isNumber());
    PrologTerm argument2 = t.getArgument(2);
    assertTrue(argument2.isVariable());
}
Also used : StructuredPrologOutput(de.prob.prolog.output.StructuredPrologOutput) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) Test(org.junit.Test)

Aggregations

StructuredPrologOutput (de.prob.prolog.output.StructuredPrologOutput)14 PrologTerm (de.prob.prolog.term.PrologTerm)10 CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)7 Test (org.junit.Test)7 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)5 RecursiveMachineLoader (de.be4.classicalb.core.parser.analysis.prolog.RecursiveMachineLoader)2 BParser (de.be4.classicalb.core.parser.BParser)1 Start (de.be4.classicalb.core.parser.node.Start)1 LtlAdapterException (de.be4.ltl.core.parser.internal.LtlAdapterException)1 ClassicalB (de.prob.animator.domainobjects.ClassicalB)1 IEvalElement (de.prob.animator.domainobjects.IEvalElement)1 ClassicalBFactory (de.prob.scripting.ClassicalBFactory)1 File (java.io.File)1 IOException (java.io.IOException)1 URL (java.net.URL)1