#include <iostream>
#include "uCalc.h"

using namespace std;
using namespace uCalcSoftware;

void ucalc_call ItemCallback(uCalcBase::Callback cb) {
   auto itm = cb.Item();
   cout << "Name: " << itm.Name() << endl;
   cout << "Data type: " << itm.DataType().Name() << endl;
   cout << "Param count: " << to_string(itm.Count()) << endl;
   cout << "Procedure type: ";
   if (itm.IsProperty(ItemIs::Operator)) {
      cout << "Operator" << endl;
   } else if (itm.IsProperty(ItemIs::Function)) {
      cout << "Function" << endl;
   }
   cout << "Definition: " << itm.Text() << endl;
   cout << "Description: " << itm.Description() << endl;
   cout << "---" << endl;
}
int main() {
   uCalc uc;
   uc.DefineFunction("AAA() As Double", ItemCallback).Description("Does this and that");
   uc.DefineFunction("BBB(x, y, z) As String", ItemCallback).Description("Does something else");
   uc.DefineOperator("{x} CCC {y} As Int32", 55, Associativity::LeftToRight, ItemCallback);

   uc.EvalStr("AAA()");
   uc.EvalStr("BBB(9, 8, 7)");
   uc.EvalStr("5 CCC 4");
}