diff --git a/pom.xml b/pom.xml index 92a8ca0..c4273b7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ fac fac - 2.3.7 + 2.3.8 diff --git a/src/main/java/parser/parsetree/BinaryOperator.java b/src/main/java/parser/parsetree/BinaryOperator.java index d849e7b..d207009 100644 --- a/src/main/java/parser/parsetree/BinaryOperator.java +++ b/src/main/java/parser/parsetree/BinaryOperator.java @@ -115,6 +115,21 @@ public enum BinaryOperator { */ PLUS("+", (a, b) -> { if (Type.getByInput(a) == Type.STRING || Type.getByInput(b) == Type.STRING) { + if (Type.getByInput(a) == Type.NUMERIC) { + double doubleValue = Double.parseDouble(a.toString()); + String result = doubleValue + ""; + if (doubleValue == Math.floor(doubleValue)) { + result = ((int) doubleValue) + ""; + } + return "'" + (result + (b.toString())).replaceAll("'", "") + "'"; + } else if (Type.getByInput(b) == Type.NUMERIC) { + double doubleValue = Double.parseDouble(b.toString()); + String result = doubleValue + ""; + if (doubleValue == Math.floor(doubleValue)) { + result = ((int) doubleValue) + ""; + } + return "'" + (a.toString() + (result)).replaceAll("'", "") + "'"; + } return "'" + (a.toString() + (b.toString())).replaceAll("'", "") + "'"; } else { return Double.parseDouble(a.toString()) + Double.parseDouble(b.toString());