using uCalcSoftware; var uc = new uCalc(); var t = new uCalc.Transformer(); // 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"); var 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. Console.WriteLine(t.Transform(code));