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

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // (See alternate version of this example using ItemOf instead of ExpressionTokens)

   // In this section underscore, _, and numeric digits
   // are accepted as part of alphanumeric tokens
   uc.DefineVariable("My_Variable = 111");
   cout << uc.Error().Message() << endl;
   uc.DefineVariable("Variable123 = 222");
   cout << uc.Error().Message() << endl;

   cout << uc.ExpressionTokens()[TokenType::AlphaNumeric].Regex() << endl;
   cout << uc.EvalStr("My_Variable") << endl;
   cout << uc.EvalStr("Variable123") << endl;
   cout << "---" << endl;

   // Now we no longer want underscore, _, or numeric digits
   // to be accepted in alphanumeric tokens; only A-Z
   uc.ExpressionTokens()[TokenType::AlphaNumeric].Regex("[a-zA-Z]+");

   uc.DefineVariable("Other_Variable = 333");
   cout << uc.Error().Message() << endl;
   uc.DefineVariable("OtherVariable123 = 444");
   cout << uc.Error().Message() << endl;

   cout << uc.EvalStr("Other_Variable") << endl;
   cout << uc.EvalStr("OtherVariable123 ") << endl;
   cout << uc.EvalStr("My_Variable") << endl;
   cout << uc.EvalStr("Variable123") << endl;
   cout << "---" << endl;

   // We restore the alphanumeric regex to support _ and numbers again
   // Note: My_Variable and Variable123 remained; they were simply inaccessible
   uc.ExpressionTokens()[TokenType::AlphaNumeric].Regex("[a-zA-Z_][a-zA-Z0-9_]*");
   cout << uc.EvalStr("My_Variable") << endl;
   cout << uc.EvalStr("Variable123") << endl;
}