Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TTool
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mbe-tools
TTool
Commits
eaa78c1d
Commit
eaa78c1d
authored
May 19, 2017
by
apvrille
Browse files
Options
Downloads
Patches
Plain Diff
Update on Testing features
parent
b33bfdc4
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Test.java
+1
-0
1 addition, 0 deletions
src/Test.java
src/myutil/BoolExpressionEvaluator.java
+72
-3
72 additions, 3 deletions
src/myutil/BoolExpressionEvaluator.java
with
73 additions
and
3 deletions
src/Test.java
+
1
−
0
View file @
eaa78c1d
...
...
@@ -121,6 +121,7 @@ public class Test {
nbOfPb
+=
evalBoolInt
(
"(3==3) or (3==4)"
,
true
,
false
);
nbOfPb
+=
evalBoolInt
(
"1<3"
,
true
,
false
);
nbOfPb
+=
evalBoolInt
(
"not(((1)==(3)))"
,
true
,
false
);
//nbOfPb += evalBoolInt("not(1==1)", false, false);
...
...
This diff is collapsed.
Click to expand it.
src/myutil/BoolExpressionEvaluator.java
+
72
−
3
View file @
eaa78c1d
...
...
@@ -184,6 +184,31 @@ public class BoolExpressionEvaluator {
return
this
;
}
public
IntBoolRes
addUnaryOperator
(
int
_op
)
{
if
((
left
!=
null
)
&&
(
right
!=
null
))
{
return
null
;
}
if
((
left
!=
null
)
&&
(
op
==
0
))
{
return
null
;
}
IntBoolRes
newE
=
new
IntBoolRes
(
BOOL_UNARY_OP
,
_op
,
this
);
if
(
left
==
null
)
{
left
=
newE
;
}
else
{
right
=
newE
;
}
IntBoolRes
topPar
=
new
IntBoolRes
();
topPar
.
father
=
newE
;
newE
.
left
=
topPar
;
return
topPar
;
}
public
IntBoolRes
addBinaryOperator
(
int
_op
)
{
// Must have at least one right operator
TraceManager
.
addDev
(
"Add binary op"
);
...
...
@@ -358,6 +383,18 @@ public class BoolExpressionEvaluator {
}
}
private
Boolean
makeUnaryOp
(
int
op
,
int
elt1
)
{
if
(
op
==
NOT_TOKEN
)
{
if
(
elt1
==
0
)
{
return
new
Boolean
(
true
);
}
else
return
new
Boolean
(
false
);
}
return
null
;
}
private
Boolean
makeBinaryOp
(
int
op
,
int
elt1
,
int
elt2
)
{
if
(
op
==
EQUAL_TOKEN
)
{
return
new
Boolean
(
elt1
==
elt2
);
...
...
@@ -391,8 +428,6 @@ public class BoolExpressionEvaluator {
return
new
Boolean
(
elt1
>=
elt2
);
}
return
null
;
}
...
...
@@ -414,6 +449,7 @@ public class BoolExpressionEvaluator {
return
new
Integer
(
elt1
/
elt2
);
}
return
null
;
}
...
...
@@ -423,6 +459,22 @@ public class BoolExpressionEvaluator {
return
getObjectValue
();
}
if
(
res
==
BOOL_UNARY_OP
)
{
if
(
left
==
null
)
{
errorMessage
=
"Badly formatted unary boolean operator"
;
return
null
;
}
Object
ob1
=
left
.
computeValue
();
if
(!(
ob1
instanceof
Boolean
))
{
errorMessage
=
"Bad operand for unary boolean operator"
;
return
null
;
}
int
elt1
=
analysisArg
(
ob1
);
Boolean
result
=
makeUnaryOp
(
op
,
elt1
);
TraceManager
.
addDev
(
"Result unary="
+
result
);
return
result
;
}
if
(
res
==
BOOL_BINARY_OP
)
{
if
((
right
==
null
)
||
(
left
==
null
))
{
errorMessage
=
"Badly formatted binary boolean operator"
;
...
...
@@ -437,7 +489,7 @@ public class BoolExpressionEvaluator {
int
elt2
=
analysisArg
(
ob2
);
Boolean
result
=
makeBinaryOp
(
op
,
elt1
,
elt2
);
TraceManager
.
addDev
(
"Result bin="
+
result
);
TraceManager
.
addDev
(
"Result bin
ary
="
+
result
);
return
result
;
}
}
...
...
@@ -476,6 +528,13 @@ public class BoolExpressionEvaluator {
return
left
.
computeValue
();
}
if
(
res
==
AVAILABLE
)
{
if
(
left
==
null
)
{
return
null
;
}
return
left
.
computeValue
();
}
errorMessage
=
"Badly formatted expression from:"
+
this
;
return
null
;
...
...
@@ -1737,6 +1796,16 @@ public class BoolExpressionEvaluator {
return
newElt
;
}
// Bool unary op
if
(
c1
==
'!'
)
{
newElt
=
current
.
addUnaryOperator
(
NOT_TOKEN
);
if
(
newElt
==
null
)
{
errorMessage
=
"Badly placed bool unary operator:"
+
token
;
return
null
;
}
return
newElt
;
}
// PARENTHESIS
if
(
c1
==
'('
)
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment