use of de.prob.prolog.output.PrologTermStringOutput in project probparsers by bendisposto.
the class ListPrologTermTest method testToTermOutput.
@Test
public void testToTermOutput() {
ListPrologTerm term = new ListPrologTerm(1, 5, new ListPrologTerm(createFixture(10)));
PrologTermStringOutput output = new PrologTermStringOutput();
term.toTermOutput(output);
assertEquals("['1','2','3','4']", output.toString());
}
use of de.prob.prolog.output.PrologTermStringOutput in project prob2 by bendisposto.
the class CommandProcessor method sendCommand.
public IPrologResult sendCommand(final AbstractCommand command) {
String query;
if (command instanceof IRawCommand) {
query = ((IRawCommand) command).getCommand();
if (!query.endsWith(".")) {
query += ".";
}
} else {
PrologTermStringOutput pto = new PrologTermStringOutput();
command.writeCommand(pto);
pto.printAtom("true");
query = pto.fullstop().toString();
}
if (logger.isDebugEnabled()) {
logger.debug(StringUtils.chomp(StringUtils.abbreviate(query, 200)));
}
String result = cli.send(query);
final Start ast = parseResult(result);
IPrologResult extractResult = extractResult(ast);
if (logger.isDebugEnabled()) {
logger.debug(StringUtils.chomp(StringUtils.abbreviate(extractResult.toString(), 200)));
}
return extractResult;
}
use of de.prob.prolog.output.PrologTermStringOutput in project prob2 by bendisposto.
the class CSPModel method checkSyntax.
@Override
public boolean checkSyntax(final String formula) {
try {
CSP element = (CSP) parseFormula(formula, FormulaExpand.TRUNCATE);
element.printProlog(new PrologTermStringOutput());
return true;
} catch (EvaluationException e) {
return false;
}
}
Aggregations