consistent toString functions for expressions, parentasis are added if neccessary

This commit is contained in:
wea_ondara
2022-07-14 18:02:18 +02:00
parent 7dafade67a
commit eb5b3a9879
14 changed files with 297 additions and 194 deletions

View File

@@ -20,10 +20,15 @@ public class AndExpression implements Expression {
return Type.AND;
}
@Override
public Priority getPriority() {
return Priority.LOGIC_AND;
}
@Override
public String toString() {
return exprs.stream().map(e -> {
if (e instanceof OrExpression) {
if (e.getPriority().getValue() < getPriority().getValue()) {
return "(" + e + ")";
} else {
return e.toString();