use of de.prob.translator.types.Tuple 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));
}
use of de.prob.translator.types.Tuple in project probparsers by bendisposto.
the class TestTranslator method testTranslateTuple.
@Test
public void testTranslateTuple() throws Exception {
Tuple o = (Tuple) Translator.translate("(1,2)");
assertTrue(o.size() == 2);
assertTrue(o.contains(Number.build("1")));
assertTrue(o.contains(Number.build("2")));
assertFalse(o.contains(Number.build("8")));
}
use of de.prob.translator.types.Tuple in project prob2 by bendisposto.
the class RuleResult method transformCounterExamples.
private void transformCounterExamples(AbstractEvalResult abstractEvalResult) {
EvalResult evalCurrent = (EvalResult) abstractEvalResult;
TranslatedEvalResult translatedResult = null;
try {
translatedResult = evalCurrent.translate();
} catch (Exception e) {
/*- fall back solution if the result can not be parsed (e.g. {1,...,1000})
* should not not happen because MAX_DISPLAY_SET is set to -1
* and hence, no truncated terms are delivered by ProBCore
* */
final String message = evalCurrent.getValue().replaceAll("\"", "");
counterExamples.add(new CounterExample(1, message));
return;
}
if (translatedResult.getValue() instanceof de.prob.translator.types.Set) {
de.prob.translator.types.Set set = (de.prob.translator.types.Set) translatedResult.getValue();
for (final BObject object : set) {
if (object instanceof Tuple) {
final Tuple tuple = (Tuple) object;
de.prob.translator.types.Number first = (de.prob.translator.types.Number) tuple.getFirst();
int errorType = first.intValue();
de.prob.translator.types.String second = (de.prob.translator.types.String) tuple.getSecond();
String message = second.getValue();
counterExamples.add(new CounterExample(errorType, message));
} else {
throw new AssertionError();
}
}
} else if (translatedResult.getValue() instanceof de.prob.translator.types.Sequence) {
de.prob.translator.types.Sequence sequence = (de.prob.translator.types.Sequence) translatedResult.getValue();
for (int i = 1; i <= sequence.size(); i++) {
de.prob.translator.types.String value = (de.prob.translator.types.String) sequence.get(i);
String message = value.getValue();
counterExamples.add(new CounterExample(i, message));
}
} else {
// fall back: should not happen
counterExamples.add(new CounterExample(1, evalCurrent.getValue()));
}
}
Aggregations