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

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Define '##' with the same precedence as 'And'. 'And' binds tighter than 'Or'.
   auto and_prec = uc.ItemOf("And", uCalc::Properties(ItemIs::Infix)).Precedence();
   auto op_handle = uc.DefineOperator("{a} ## {b} As Boolean = a and b", and_prec);

   cout << "--- Initial Precedence (like 'And') ---" << endl;
   // Evaluation is like: true or (false and false) -> true or false -> true
   cout << uc.EvalStr("true or false ## 1 == 2") << endl;

   // Now, change the precedence to be lower than 'Or'.
   auto or_prec = uc.ItemOf("Or", uCalc::Properties(ItemIs::Infix)).Precedence();
   op_handle.Precedence(or_prec - 10);

   cout << "" << endl;
   cout << "--- Changed Precedence (lower than 'Or') ---" << endl;
   // Evaluation is like: (true or false) and false -> true and false -> false
   cout << uc.EvalStr("true or false ## 1 == 2") << endl;
}