Search in sources :

Example 1 with PResult

use of de.prob.core.sablecc.node.PResult in project probparsers by bendisposto.

the class PrologTermGenerator method toPrologTerm.

public static PrologTerm toPrologTerm(final Start node) throws ResultParserException {
    PResult topnode = node.getPResult();
    PrologTerm term = null;
    if (topnode instanceof AYesResult) {
        term = toPrologTerm(((AYesResult) topnode).getTerm());
    } else if (topnode instanceof ANoResult) {
        term = null;
    } else if (topnode instanceof AInterruptedResult) {
        term = null;
    } else if (topnode instanceof AExceptionResult) {
        String message = "ProB raised an exception: " + ((AExceptionResult) topnode).getString().getText();
        throw new ResultParserException(message, null);
    } else
        throw new IllegalStateException("Unknown subclass of PResult: " + topnode.getClass().getCanonicalName());
    return term;
}
Also used : AYesResult(de.prob.core.sablecc.node.AYesResult) AInterruptedResult(de.prob.core.sablecc.node.AInterruptedResult) AExceptionResult(de.prob.core.sablecc.node.AExceptionResult) PResult(de.prob.core.sablecc.node.PResult) ANoResult(de.prob.core.sablecc.node.ANoResult) CompoundPrologTerm(de.prob.prolog.term.CompoundPrologTerm) ListPrologTerm(de.prob.prolog.term.ListPrologTerm) PrologTerm(de.prob.prolog.term.PrologTerm) VariablePrologTerm(de.prob.prolog.term.VariablePrologTerm) IntegerPrologTerm(de.prob.prolog.term.IntegerPrologTerm)

Aggregations

AExceptionResult (de.prob.core.sablecc.node.AExceptionResult)1 AInterruptedResult (de.prob.core.sablecc.node.AInterruptedResult)1 ANoResult (de.prob.core.sablecc.node.ANoResult)1 AYesResult (de.prob.core.sablecc.node.AYesResult)1 PResult (de.prob.core.sablecc.node.PResult)1 CompoundPrologTerm (de.prob.prolog.term.CompoundPrologTerm)1 IntegerPrologTerm (de.prob.prolog.term.IntegerPrologTerm)1 ListPrologTerm (de.prob.prolog.term.ListPrologTerm)1 PrologTerm (de.prob.prolog.term.PrologTerm)1 VariablePrologTerm (de.prob.prolog.term.VariablePrologTerm)1