00001 #include <stdio.h> 00002 #include "StringValue.h" 00003 #include "InputParser.h" 00004 #include "IntValue.h" 00005 #include "BoolValue.h" 00006 00007 int main(int argc, char **argv) { 00008 CValue* contextval = new CIntValue(10,"someobject"); 00009 00010 00011 CValue* healthprop = new CIntValue(20,"health"); 00012 CValue* deltahealth = new CIntValue(5,"delta"); 00013 00014 healthprop->SetProperty(deltahealth); 00015 contextval->SetProperty(healthprop); 00016 00017 contextval->SetProperty(new CIntValue(10,"shield")); 00018 00019 00020 CCString blaat="(1+3)*2"; 00021 00022 CParser parser; 00023 parser.SetContext(contextval->AddRef()); 00024 00025 CExpression *expr = parser.ProcessText(blaat); 00026 00027 if (expr) { 00028 CValue *result = expr->Calculate(); 00029 if (result) { 00030 CCString str = result->GetText(); 00031 char *bla = (char *)str; 00032 printf("%s\n", (char *)str); 00033 result->Release(); 00034 } 00035 expr->Release(); 00036 } 00037 00038 contextval->Release(); 00039 00040 return(0); 00041 } 00042