private bool Compile() { CompileStatus.Text = "Compiling..."; if (Parser.Parse(MyTextEditor.Text.ToCharArray())) { try { SyntaxTree syntaxtree = SyntaxAnalyzer.GetTree(Parser.Tokens); ArrayList InstructionCode = new ArrayList(); NumberAndIdentifierTable nids = new NumberAndIdentifierTable(); CodeGenerator.GenerateCode(InstructionCode, nids, syntaxtree); if (CurrentFile == "") { CodeGenerator.SaveFile(InstructionCode, nids, Application.StartupPath + "\\Tempfile.imc"); } else { FileInfo finfo = new FileInfo(CurrentFile); CodeGenerator.SaveFile( InstructionCode, nids, Path.ChangeExtension(CurrentFile, "imc")); } CompileStatus.Text = "Compilation process completed successfully."; return(true); } catch (Exception exc) { MyTextEditor.Select((int)SyntaxAnalyzer.CurrentToken.startpointer, (int)(SyntaxAnalyzer.CurrentToken.endpointer - SyntaxAnalyzer.CurrentToken.startpointer)); CompileStatus.Text = "Error occured, compilation failed."; } } else { foreach (Token tkn in Parser.Tokens) { if (tkn.TType == TokenType.ERROR) { MyTextEditor.Select((int)tkn.startpointer, (int)(tkn.endpointer - tkn.startpointer)); CompileStatus.Text = "Error occured, compilation failed."; break; } } } return(false); }