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); 00009 00010 00011 CValue* healthprop = new CIntValue(20); 00012 CValue* deltahealth = new CIntValue(5); 00013 00014 healthprop->SetProperty("deltahealth",deltahealth); 00015 contextval->SetProperty("health",healthprop); 00016 00017 contextval->SetProperty("shield",new CIntValue(10)); 00018 00019 00020 CCString blaat=CCString("(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 const char *bla = (const char *)str; 00032 printf("%s = %s\n",(const char*)blaat, (const char *)str); 00033 result->Release(); 00034 } 00035 expr->Release(); 00036 } 00037 00038 contextval->Release(); 00039 00040 return(0); 00041 } 00042