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();
}
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);
}
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);
}
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);
}
}
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());
}
Aggregations