Skip to content

Commit

Permalink
hopefully the last beauty fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lpapailiou committed Jul 4, 2021
1 parent 1d9da5c commit a40c4c5
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>fac</groupId>
<artifactId>fac</artifactId>
<version>2.3.7</version>
<version>2.3.8</version>

<dependencies>
<dependency>
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/parser/parsetree/BinaryOperator.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit a40c4c5

Please sign in to comment.