Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      Using t As 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
         Dim ifRule = t.FromTo("IF {condition} THEN {action}", "if ({condition}) {
  {action}
}")
         ifRule.RewindOnChange = true
         
         '// The legacy script to transpile
         Dim 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))
      End Using
   End Sub
End Module