use of de.prob.translator.types.BObject in project probparsers by bendisposto.
the class TranslatingVisitor method listToSet.
private java.util.Set<BObject> listToSet(LinkedList<PExpression> elements) {
java.util.Set<BObject> s = de.prob.translator.types.Set.newStorage();
for (PExpression p : elements) {
p.apply(this);
s.add(this.getResult());
}
return s;
}
use of de.prob.translator.types.BObject in project probparsers by bendisposto.
the class TranslatingVisitor method caseARecEntry.
@Override
public void caseARecEntry(ARecEntry node) {
Atom key = null;
BObject value = null;
node.getIdentifier().apply(this);
key = (Atom) this.getResult();
node.getValue().apply(this);
value = this.getResult();
this.setResult(new RecordEntry(key, value));
}
use of de.prob.translator.types.BObject in project probparsers by bendisposto.
the class TranslatingVisitor method caseARecExpression.
@Override
public void caseARecExpression(ARecExpression node) {
Map<java.lang.String, BObject> s = Record.newStorage();
// TODO or make the record immutable after filling it
for (PRecEntry e : node.getEntries()) {
e.apply(this);
RecordEntry entry = (RecordEntry) this.getResult();
s.put(entry.getKey().getValue(), entry.getValue());
}
this.setResult(new Record(s));
}
use of de.prob.translator.types.BObject 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