Search in sources :

Example 1 with BObject

use of de.prob.translator.types.BObject in project probparsers by bendisposto.

the class TranslatingVisitor method caseACoupleExpression.

@Override
public void caseACoupleExpression(ACoupleExpression node) {
    List<BObject> s = new ArrayList<BObject>();
    for (PExpression e : node.getList()) {
        e.apply(this);
        s.add(this.getResult());
    }
    this.setResult(new Tuple(s));
}
Also used : BObject(de.prob.translator.types.BObject) ArrayList(java.util.ArrayList) PExpression(de.be4.classicalb.core.parser.node.PExpression) Tuple(de.prob.translator.types.Tuple)

Example 2 with BObject

use of de.prob.translator.types.BObject in project probparsers by bendisposto.

the class TranslatingVisitor method getResult.

public BObject getResult() {
    if (this.result == null) {
        throw new IllegalStateException("Trying to read a missing intermediate result. This might be a missing case in the translator");
    }
    BObject res = this.result;
    this.result = null;
    return res;
}
Also used : BObject(de.prob.translator.types.BObject)

Example 3 with BObject

use of de.prob.translator.types.BObject in project probparsers by bendisposto.

the class TranslatingVisitor method caseASequenceExtensionExpression.

@Override
public void caseASequenceExtensionExpression(ASequenceExtensionExpression node) {
    List<BObject> s = new ArrayList<BObject>();
    for (PExpression e : node.getExpression()) {
        e.apply(this);
        s.add(this.getResult());
    }
    this.setResult(new Sequence(s));
}
Also used : BObject(de.prob.translator.types.BObject) ArrayList(java.util.ArrayList) Sequence(de.prob.translator.types.Sequence) PExpression(de.be4.classicalb.core.parser.node.PExpression)

Example 4 with BObject

use of de.prob.translator.types.BObject in project prob2 by bendisposto.

the class EvalResult method translate.

public TranslatedEvalResult translate() throws BCompoundException {
    BObject val = Translator.translate(value);
    Map<String, BObject> sols = new HashMap<>();
    Set<Entry<String, String>> entrySet = solutions.entrySet();
    for (Entry<String, String> entry : entrySet) {
        sols.put(entry.getKey(), Translator.translate(entry.getValue()));
    }
    return new TranslatedEvalResult(val, sols);
}
Also used : BObject(de.prob.translator.types.BObject) Entry(java.util.Map.Entry) HashMap(java.util.HashMap)

Example 5 with BObject

use of de.prob.translator.types.BObject in project probparsers by bendisposto.

the class TestTranslator method testTranslateAnything.

@Test
public void testTranslateAnything() throws Exception {
    BObject o = Translator.translate("5");
    assertNotNull(o);
}
Also used : BObject(de.prob.translator.types.BObject) Test(org.junit.Test)

Aggregations

BObject (de.prob.translator.types.BObject)9 PExpression (de.be4.classicalb.core.parser.node.PExpression)3 Tuple (de.prob.translator.types.Tuple)2 ArrayList (java.util.ArrayList)2 PRecEntry (de.be4.classicalb.core.parser.node.PRecEntry)1 AbstractEvalResult (de.prob.animator.domainobjects.AbstractEvalResult)1 EvalResult (de.prob.animator.domainobjects.EvalResult)1 TranslatedEvalResult (de.prob.animator.domainobjects.TranslatedEvalResult)1 Atom (de.prob.translator.types.Atom)1 Record (de.prob.translator.types.Record)1 Sequence (de.prob.translator.types.Sequence)1 String (de.prob.translator.types.String)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1 Set (java.util.Set)1 Test (org.junit.Test)1