#include #include "uCalc.h" using namespace std; using namespace uCalcSoftware; int main() { uCalc uc; uCalc::Transformer t; // Turn single-line comments into whitespace tokens (to be ignored) t.Tokens().Add("//.*", TokenType::Whitespace); // Define a rule to replace the alphanumeric token 'x' with 'value' t.FromTo("x", "value"); auto code = "x = 10; print('The max value is x.'); // x is 10 here"; // The Transformer correctly identifies that only the first 'x' is // a token on its own. Imbedded occurrences of 'x' are left alone. cout << t.Transform(code) << endl; }