example: if (leftExpression ==RightExpressi on)
After parsing I know the type of RightExpression .
I suppone that if RightExpression is wrap into " " is a String.
else I check if RightExpression is a int.
else In final case, I check that RightExpression is a name of object
defined in my environment.
Environment keep association between name and object instance and is a
dictionary.
From environment and leftExpression string I get leftExpression Object.
How can I compare leftExpression and RightExpression object?
operator can be == != < >
I don't like how write this code.
Exist a way more generic to do it?
I would like a way to avoid thousand case.
bool Compare(Object leftExpression, Object RightExpression ,String op)
{
if (RightExpressio n is int)
{
if (LeftExpression is int)
{
int RightExpression =(int) RightExpression ;
int LeftExpression= (int) LeftExpression;
if op.Equals("==")
{
return (RightExpressio n.Equals(LeftEx pression));
}
if op.Equals("<") returnRightExpr ession<LeftExpr ession)
...
...
}
else return false;
else if (RightExpressio n is String)
{
if (LeftExpression is String)
{
String RightExpression =(String) RightExpression ;
String LeftExpression= (String) LeftExpression;
.....
}
else // RightExpression and LeftExpression is generic type how
compare?
{
}
}