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

using namespace std;
using namespace uCalcSoftware;

#define tf(IsTrue) ((IsTrue) ? "True" : "False")

int main() {
   uCalc uc;
   uCalc uc1;
   uc1.DefineVariable("val = 100");

   uCalc uc2;
   uc2.DefineVariable("val = 200");

   // Create the transformer in uc1's context
   auto t = uc1.NewTransformer();
   t.Text("data");
   t.Pattern("data");
   t.Find();

   auto m = t.Matches();
   auto parent_uc = m.uCalc();

   cout << "Parent has value: " << parent_uc.Eval("val") << endl;
   cout << "Is parent uc1? " << tf(parent_uc.MemoryIndex() == uc1.MemoryIndex()) << endl;
   cout << "Is parent uc2? " << tf(parent_uc.MemoryIndex() == uc2.MemoryIndex()) << endl;
}