example: if (leftExpression==RightExpression)
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 (RightExpression is int)
{
if (LeftExpression is int)
{
int RightExpression=(int) RightExpression;
int LeftExpression=(int) LeftExpression;
if op.Equals("==")
{
return (RightExpression.Equals(LeftExpression));
}
if op.Equals("<") returnRightExpression<LeftExpression)
...
...
}
else return false;
else if (RightExpression is String)
{
if (LeftExpression is String)
{
String RightExpression=(String) RightExpression;
String LeftExpression=(String) LeftExpression;
.....
}
else // RightExpression and LeftExpression is generic type how
compare?
{
}
}