From 8bbe9acbe84a074daf1b23b34042c30e1ab2004a Mon Sep 17 00:00:00 2001
From: Ludovic Apvrille <ludovic.apvrille@telecom-paris.fr>
Date: Tue, 13 Apr 2021 10:40:01 +0200
Subject: [PATCH] Resolving bug on bool var

---
 .../avatartranslator/AvatarSyntaxChecker.java   | 17 ++++++++++++++---
 .../java/ui/AvatarDesignPanelTranslator.java    |  9 ++++++---
 2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/src/main/java/avatartranslator/AvatarSyntaxChecker.java b/src/main/java/avatartranslator/AvatarSyntaxChecker.java
index 9c3fe321cc..2ac599b6ea 100644
--- a/src/main/java/avatartranslator/AvatarSyntaxChecker.java
+++ b/src/main/java/avatartranslator/AvatarSyntaxChecker.java
@@ -334,14 +334,19 @@ public class AvatarSyntaxChecker  {
         String tmp = _expr.replaceAll(" ", "").trim();
         String act = tmp;
 
+
+        //TraceManager.addDev("1. IsValidBoolExpr Evaluating bool:" + act);
+
         for(AvatarAttribute aa: _ab.getAttributes()) {
-            act = Conversion.putVariableValueInString(AvatarSpecification.ops, act, aa.getName(), aa.getDefaultInitialValueTF());
+            act = Conversion.putVariableValueInString(AvatarSpecification.ops, act, aa.getName(), aa.getDefaultInitialValue());
         }
 
+        //TraceManager.addDev("2. IsValidBoolExpr Evaluating bool:" + act);
+
 
         BoolExpressionEvaluator bee = new BoolExpressionEvaluator();
 
-        //TraceManager.addDev("IsValidBoolExpr Evaluating bool:" + act);
+
         boolean result = bee.getResultOfWithIntExpr(act);
         if (bee.getError() != null) {
             TraceManager.addDev("Error in bool expr: " + bee.getError());
@@ -351,11 +356,17 @@ public class AvatarSyntaxChecker  {
         }
 
         // Testing with parsing AvatarExpressionSolver
-        AvatarExpressionSolver aee = new AvatarExpressionSolver(_expr);
+
+        //TraceManager.addDev("3. Now with avatar expression solver:" + _expr);
+
+        AvatarExpressionSolver aee = new AvatarExpressionSolver(act);
         if ( !(aee.buildExpression())) {
+            TraceManager.addDev("4. Error with avatar expression solver:" + act);
             return -1;
         }
 
+        //TraceManager.addDev("4. Ok with avatar expression solver:" + act);
+
         return 0;
         // OLD return parse(_as, _ab, "actionbool", _expr);
     }
diff --git a/src/main/java/ui/AvatarDesignPanelTranslator.java b/src/main/java/ui/AvatarDesignPanelTranslator.java
index bebedc42bc..eb99e3df94 100644
--- a/src/main/java/ui/AvatarDesignPanelTranslator.java
+++ b/src/main/java/ui/AvatarDesignPanelTranslator.java
@@ -1738,15 +1738,18 @@ public class AvatarDesignPanelTranslator {
             for (int i = 0; i < aaos.getNbOfValues(); i++) {
                 String theVal = aaos.getValue(i);
                 if (atas.getListOfAttributes().get(i).isInt()) {
-                    if (AvatarSyntaxChecker.isAValidIntExpr(_as, _ab, modifyString(theVal)) < 0)
-                        //TraceManager.addDev("theVal=" + modifyString(theVal));
+                    if (AvatarSyntaxChecker.isAValidIntExpr(_as, _ab, modifyString(theVal)) < 0) {
+                        TraceManager.addDev("Error 1. TheVal=" + modifyString(theVal));
                         throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdss.getValue()
                                 + " -> value at index #" + i + " does not match definition");
+                    }
                 } else {
                     // We assume it is a bool attribute
-                    if (AvatarSyntaxChecker.isAValidBoolExpr(_as, _ab, modifyString(theVal)) < 0)
+                    if (AvatarSyntaxChecker.isAValidBoolExpr(_as, _ab, modifyString(theVal)) < 0) {
+                        TraceManager.addDev("Error 2. TheVal=" + modifyString(theVal));
                         throw new CheckingError(CheckingError.BEHAVIOR_ERROR, "Badly formed signal receiving: " + asmdss.getValue()
                                 + " -> value at index #" + i + " does not match definition");
+                    }
                 }
             }
 
-- 
GitLab