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

using namespace std;
using namespace uCalcSoftware;

int main() {
   uCalc uc;
   // Using {@Whitespace} to Count Indentation
   // A common use case for parsing structured text (like Python or YAML)
   // is capturing the exact whitespace at the start of a line.

   uc.DefineVariable("IndentLen");

   auto t = uc.NewTransformer();
   t.Text("    Item 1"); // Indented by 4 spaces

   // Capture the leading whitespace into 'w' and evaluate its length
   t.FromTo("{@Whitespace:w} Item {id}", "<{@Self}>{@Exec: IndentLen = Length(w)}");
   t.Transform();
   // We can now analyze the captured whitespace
   cout << "Indentation length: " << uc.EvalStr("IndentLen") << endl;
}