From c3aa5942b2ef1c44f3a1156c8c14ca612f228e81 Mon Sep 17 00:00:00 2001 From: coderbot Date: Tue, 21 Dec 2021 16:06:22 -0800 Subject: [PATCH] Remove ExpressionElement#simplify --- .../java/kroppeb/stareval/element/ExpressionElement.java | 6 ------ .../stareval/element/tree/BinaryExpressionElement.java | 7 ------- .../java/kroppeb/stareval/element/tree/FunctionCall.java | 9 --------- .../stareval/element/tree/UnaryExpressionElement.java | 6 ------ src/test/java/kroppeb/stareval/parser/ParserTest.java | 7 ++++--- 5 files changed, 4 insertions(+), 31 deletions(-) diff --git a/src/main/java/kroppeb/stareval/element/ExpressionElement.java b/src/main/java/kroppeb/stareval/element/ExpressionElement.java index 42768b093a..6fa53b1002 100644 --- a/src/main/java/kroppeb/stareval/element/ExpressionElement.java +++ b/src/main/java/kroppeb/stareval/element/ExpressionElement.java @@ -1,10 +1,4 @@ package kroppeb.stareval.element; public interface ExpressionElement extends Element { - @Override - String toString(); - - default ExpressionElement simplify() { - return this; - } } diff --git a/src/main/java/kroppeb/stareval/element/tree/BinaryExpressionElement.java b/src/main/java/kroppeb/stareval/element/tree/BinaryExpressionElement.java index 884b91a1c9..c20e2f5934 100644 --- a/src/main/java/kroppeb/stareval/element/tree/BinaryExpressionElement.java +++ b/src/main/java/kroppeb/stareval/element/tree/BinaryExpressionElement.java @@ -18,11 +18,4 @@ public BinaryExpressionElement(BinaryOp op, ExpressionElement left, ExpressionEl public String toString() { return "BinaryExpr{ {" + this.left + "} " + this.op + " {" + this.right + "} }"; } - - @Override - public ExpressionElement simplify() { - this.left = this.left.simplify(); - this.right = this.right.simplify(); - return this; - } } diff --git a/src/main/java/kroppeb/stareval/element/tree/FunctionCall.java b/src/main/java/kroppeb/stareval/element/tree/FunctionCall.java index 405c651db0..0e779e4348 100644 --- a/src/main/java/kroppeb/stareval/element/tree/FunctionCall.java +++ b/src/main/java/kroppeb/stareval/element/tree/FunctionCall.java @@ -17,13 +17,4 @@ public FunctionCall(String id, List args) { public String toString() { return "FunctionCall{" + this.id + " {" + this.args + "} }"; } - - @Override - public ExpressionElement simplify() { - for (int i = 0; i < this.args.size(); i++) { - this.args.set(i, this.args.get(i).simplify()); - } - - return this; - } } diff --git a/src/main/java/kroppeb/stareval/element/tree/UnaryExpressionElement.java b/src/main/java/kroppeb/stareval/element/tree/UnaryExpressionElement.java index d2ecd3705d..5467751248 100644 --- a/src/main/java/kroppeb/stareval/element/tree/UnaryExpressionElement.java +++ b/src/main/java/kroppeb/stareval/element/tree/UnaryExpressionElement.java @@ -16,10 +16,4 @@ public UnaryExpressionElement(UnaryOp op, ExpressionElement inner) { public String toString() { return "UnaryExpr{" + this.op + " {" + this.inner + "} }"; } - - @Override - public ExpressionElement simplify() { - this.inner = this.inner.simplify(); - return this; - } } diff --git a/src/test/java/kroppeb/stareval/parser/ParserTest.java b/src/test/java/kroppeb/stareval/parser/ParserTest.java index bb57a5a384..f7e1b3d8ff 100644 --- a/src/test/java/kroppeb/stareval/parser/ParserTest.java +++ b/src/test/java/kroppeb/stareval/parser/ParserTest.java @@ -1,5 +1,6 @@ package kroppeb.stareval.parser; +import kroppeb.stareval.element.Element; import kroppeb.stareval.exception.ParseException; import kroppeb.stareval.element.ExpressionElement; import org.junit.jupiter.params.ParameterizedTest; @@ -37,8 +38,8 @@ void checkIfInvalidExpressionsDontParse(String input) { @ParameterizedTest @CsvFileSource(resources = "/fullyEquivalent.csv", delimiter = ';') void checkOrderOfOperationsParse(String input1, String input2) throws ParseException { - ExpressionElement exp1 = parse(input1); - ExpressionElement exp2 = parse(input2); - assertEquals(exp1.simplify().toString(), exp2.simplify().toString()); + Element exp1 = parse(input1); + Element exp2 = parse(input2); + assertEquals(exp1.toString(), exp2.toString()); } }