public void JavaScript_Complex() { var generator = new JavaScriptGenerator(); var generated = generator.Generate(Ast.Complex()); Console.WriteLine(generated); }
public static void Main() { // Read the Vale code from roguelike-small.vale. string valeCode = File.ReadAllText("roguelike-small.vale"); Console.WriteLine("Compiling..."); // This sends a request to the Vale compile server, and // results in some JSON representing VIR (Vale Intermediate Representation). string astJson = ValeHelper.Build(valeCode); // Uncomment this to see it! // Console.WriteLine(astJson); // Deserialize the VIR into AstModel instances. var ast = (IProgram)Json.Deserialize <AstModel>(astJson); Console.WriteLine("Cross-compiling to Javascript..."); // Convert the VIR into Javascript, and write to output.js using (var outputFileStream = File.Create("output.js")) { using (var outputFileStreamWriter = new StreamWriter(outputFileStream, Encoding.ASCII)) { foreach (var code in JavaScriptGenerator.Generate(ast)) { outputFileStreamWriter.Write(code); } } } // We're done! Console.WriteLine("Compiling done! Now run with:"); Console.WriteLine(" node output.js"); }
public ActionResult JavaScript(Block block) { var generator = new JavaScriptGenerator(); var generated = generator.Generate(block); return(Content(generated)); }
void convertButton_Click(object sender, EventArgs e) { CompileResult result = JavaScriptGenerator.Generate(basicSourceTB.Text); if (result.IsSuccessful) { javascriptSourceTB.Text = @" function runProgram() { run('console', 22, 40, " + result.StartFunction + @"); } "; javascriptSourceTB.Text += result.JavaScript; } else { javascriptSourceTB.Text = "COMPILE ERROR" + Environment.NewLine + Environment.NewLine + result.ResultMessage; } }