#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; #define tf(IsTrue) ((IsTrue) ? "True" : "False") int main() { uCalc uc; uCalc root_uc; root_uc.Description("Root uCalc Instance"); uCalc::Transformer main_t(root_uc); // Create a rule in the main transformer auto outerRule = main_t.Pattern("OUTER({body})"); // Get a local transformer for the outer rule auto local_t = outerRule.LocalTransformer(); local_t.Description("Local Transformer"); // Create an inner rule inside the local transformer auto innerRule = local_t.FromTo("INNER", "inner_match"); // Verify both rules resolve to the same root uCalc instance auto outerParent = outerRule.uCalc(); auto innerParent = innerRule.uCalc(); cout << "Outer rule's parent: " << outerParent.Description() << endl; cout << "Inner rule's parent: " << innerParent.Description() << endl; cout << "Both rules share the same root uCalc instance: " << tf(outerParent.Handle() == innerParent.Handle()) << endl; }