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

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Internal Test: Verifies precedence and tag retrieval via NextOverload
   uCalc::Transformer t;
   t.Text("Testing (a b c) Testing x y z! Testing 1 2 3.");

   // Rules defined last have higher precedence for the same anchor ("Testing")
   auto p1 = t.Pattern("Testing {etc}.").SetTag(111);
   auto p2 = t.Pattern("Testing {etc}!").SetTag(222);
   auto p3 = t.Pattern("Testing ({etc})").SetTag(333);

   // Get the highest precedence rule via Pattern's return value
   auto highestPriorityRule = p3;
   cout << "Highest priority rule tag: " << highestPriorityRule.Tag() << endl;

   // Walk the overload chain
   auto midPriorityRule = highestPriorityRule.NextOverload();
   cout << "Mid priority rule tag: " << midPriorityRule.Tag() << endl;

   auto lowPriorityRule = midPriorityRule.NextOverload();
   cout << "Low priority rule tag: " << lowPriorityRule.Tag() << endl;

   // The end of the chain should have a tag of 0 (default)
   auto endOfChain = lowPriorityRule.NextOverload();
   cout << "End of chain tag: " << endOfChain.Tag() << endl;
}