Skip to content
Snippets Groups Projects
Commit f84cfd80 authored by Ludovic Apvrille's avatar Ludovic Apvrille
Browse files

Update on intexpr parsing after Florian patch

parent 970be8cd
No related branches found
No related tags found
No related merge requests found
......@@ -60,11 +60,12 @@ public class AvatarTuple extends AvatarLeftHand {
public static AvatarTuple createFromString (AvatarStateMachineOwner block, String toParse) {
AvatarTuple result = null;
toParse = toParse.trim();
if (toParse.trim().startsWith("(")) {
if (toParse.startsWith("(")) {
int indexLParen = toParse.indexOf ("(");
int indexRParen = AvatarGuard.getMatchingRParen (toParse, indexLParen);
if (indexRParen < 0)
if (indexRParen != toParse.length () - 1)
return null;
String[] components = toParse.substring (indexLParen+1, indexRParen).trim().split (",");
boolean illFormed = false;
......
......@@ -129,13 +129,15 @@ public class AvatarIntegerExprParsingAndEvaluationTests {
testExpr("x = x + x*(y+z)*(x - z)", 570, true);
//testExpr("x = (x + y)*z", 30, true);
testExpr("x = (x + y)*z", 30, true);
//testExpr("x = (x + y)*z + (x+z)/z", 36, true);
testExpr("x = (x + y)*z + (x+z)/z", 36, true);
testExpr("x = x*((x + y)*z + (x+z)/z)", 360, true);
testExpr("x = x*((x + y)*z + (x+z)/z)/x", 36, true);
/*res= AvatarGuard.createFromString(A, "else");
assertTrue(res instanceof AvatarGuardElse);*/
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment