using uCalcSoftware; var uc = new uCalc(); using (var t = new uCalc.Transformer()) { // Rules must be defined in an order that allows for proper transformation. // 1. Comment rule t.FromTo("REM {comment}", "// {comment}"); // 2. Variable assignment rule t.FromTo("LET {@Alpha:var} = {val}", "var {var} = {val};"); // 3. Print statement rule t.FromTo("PRINT {output}", "console.log({output});"); // 4. IF...THEN rule with RewindOnChange to handle nested statements var ifRule = t.FromTo("IF {condition} THEN {action}", """ if ({condition}) { {action} } """); ifRule.RewindOnChange = true; // The legacy script to transpile var legacyScript = """ REM Initialize variables LET X = 10 LET Y = X * 2 IF Y > 15 THEN PRINT "Value is large" """; // Run the transformation Console.WriteLine(t.Transform(legacyScript)); }