Search in sources :

Example 6 with PrologTermStringOutput

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());
}
Also used : PrologTermStringOutput(de.prob.prolog.output.PrologTermStringOutput) Test(org.junit.Test)

Example 7 with PrologTermStringOutput

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;
}
Also used : Start(de.prob.core.sablecc.node.Start) PrologTermStringOutput(de.prob.prolog.output.PrologTermStringOutput) IRawCommand(de.prob.animator.command.IRawCommand)

Example 8 with PrologTermStringOutput

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;
    }
}
Also used : CSP(de.prob.animator.domainobjects.CSP) PrologTermStringOutput(de.prob.prolog.output.PrologTermStringOutput) EvaluationException(de.prob.animator.domainobjects.EvaluationException)

Aggregations

PrologTermStringOutput (de.prob.prolog.output.PrologTermStringOutput)8 ASTProlog (de.be4.classicalb.core.parser.analysis.prolog.ASTProlog)3 Start (de.be4.classicalb.core.parser.node.Start)3 Test (org.junit.Test)3 BParser (de.be4.classicalb.core.parser.BParser)2 ClassicalPositionPrinter (de.be4.classicalb.core.parser.analysis.prolog.ClassicalPositionPrinter)2 NodeIdAssignment (de.be4.classicalb.core.parser.analysis.prolog.NodeIdAssignment)2 BCompoundException (de.be4.classicalb.core.parser.exceptions.BCompoundException)2 LexerException (de.be4.classicalb.core.parser.lexer.LexerException)1 LtlParseException (de.be4.ltl.core.parser.LtlParseException)1 IRawCommand (de.prob.animator.command.IRawCommand)1 CSP (de.prob.animator.domainobjects.CSP)1 EvaluationException (de.prob.animator.domainobjects.EvaluationException)1 Start (de.prob.core.sablecc.node.Start)1 PrologTerm (de.prob.prolog.term.PrologTerm)1 IOException (java.io.IOException)1