private bool Compile() { if (this.dirtyFlag) { if (MessageBox.Show("Save file before compiling?", "Save File?", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { this.SaveCode(); } } this.Status = "Compiling Code..."; this.outputTextBox.Text = ""; PsudoCompiler compiler = new PsudoCompiler(this.codeRichTextBox.Text); if (compiler.CheckSyntax()) { if (compiler.Compile()) { this.program = compiler.program; this.compileInfo = compiler; this.PrintCompilerData(compiler); this.Status = "Compile Successful"; return(true); } else { this.AppendText("Compile Failed\n\n", Color.Red); this.Status = "Compile Failed"; foreach (CompileError error in compiler.Errors) { this.AppendText( string.Format("Line {0}: {1}\n", error.Line, error.Details), Color.Red); } } } else { this.AppendText("Invalid Syntax\n\n", Color.Red); this.Status = "Invalid Syntax"; foreach (CompileError error in compiler.scanner.errors) { this.AppendText( string.Format("Line {0}: {1}\n", error.Line, error.Details), Color.Red); } } return(false); }
private void PrintCompilerData(PsudoCompiler compiler) { this.outputTextBox.Text = ""; foreach (var item in compiler.program.Classes) { this.AppendText( string.Format("Class: {0}, Methods: {1}, Vars {2}", item.Value.Name, item.Value.Methods.Count, item.Value.ClassVariables.Count ), Color.White); } }