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

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Create a transformer with a custom comment token definition
   uCalc::Transformer t_source;
   auto commentToken = t_source.Tokens().Add(R"(/\*([\s\S]*?)\*/)", TokenType::Whitespace);
   commentToken.Description("C-style block comment");

   // Create a second transformer that will do replacements
   uCalc::Transformer t_replacer;
   t_replacer.FromTo("secret", "REDACTED");

   auto sourceText = "a secret /* contains another secret */ value";

   cout << "--- Before Importing Comment Token ---" << endl;
   // Without knowing about comments, t_replacer incorrectly modifies the text inside the comment.
   cout << t_replacer.Transform(sourceText) << endl;
   cout << "" << endl;

   cout << "--- After Importing Comment Token ---" << endl;
   // Import the comment token definition. Now, the comment block is treated as a single whitespace token.
   t_replacer.Tokens().Add(commentToken);
   // The transformer must be reset with the original text for the new token to apply.
   t_replacer.Text(sourceText);
   cout << t_replacer.Transform() << endl;
}