From a40c4c59756552dc647e3353343e938d1c3552ee Mon Sep 17 00:00:00 2001 From: lpapailiou Date: Sun, 4 Jul 2021 23:33:41 +0200 Subject: [PATCH] hopefully the last beauty fix --- pom.xml | 2 +- .../java/parser/parsetree/BinaryOperator.java | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) 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());