private async Task DoCompilation()
        {
            foreach (var item in fileListView.Items)
            {
                try
                {
                    string sourceFileName = (item as Label).Content.ToString();
                    string sourceCode     = await File.ReadAllTextAsync(sourceFileName);

                    var compiled = compiler.Compile(sourceCode);

                    string outputFileName = Path.Combine(outputPathBox.Text, Path.GetFileName(sourceFileName) + ".py");
                    await File.WriteAllTextAsync(outputFileName, compiled);
                }
                catch (Exception ex)
                {
                    Console.WriteLine($"Error during compilation: {ex}");
                }
            }
        }
Exemple #2
0
        public IActionResult OnPost(string submit)
        {
            if (submit == "Compile")
            {
                if (string.IsNullOrWhiteSpace(InputCode))
                {
                    return(null);
                }

                var compiler = new TomScriptCompiler(InputCode);
                GeneratedCode = compiler.Compile();
            }
            else if (submit == "Download")
            {
                if (string.IsNullOrWhiteSpace(GeneratedCode))
                {
                    return(null);
                }

                return(DownloadGeneratedCodeFile());
            }
            return(null);
        }
        private void CompileCode()
        {
            var output = compiler.Compile(sourceTextBox.Text);

            outputTextBox.Text = output;
        }