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

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // The transformer 't' belongs to the main 'uc' instance.
   uCalc::Transformer t(uc);

   // Define a variable in the transformer's parent context.
   t.uCalc().DefineVariable("VarX = 123");

   // This rule is created within 't' and will need to access VarX.
   auto myRule = t.FromTo("x", "{@Eval: VarX}");

   // Get the rule's parent uCalc instance...
   auto parent_uc = myRule.uCalc();

   // ...and use it to evaluate an expression to prove we have the right context.
   cout << "Value of VarX in parent context: " << parent_uc.Eval("VarX") << endl;

   // Now, run the transformation. The {@Eval} in the rule
   // correctly finds 'VarX' in its parent uCalc context.
   cout << t.Transform("The value is: x") << endl;
}