private void SyntaxCheck(object parameter) { var document = parameter as FlowDocument; if (document == null) { return; } ErrorMessages.Clear(); try { // gets the current content of the editor var content = new TextRange(document.ContentStart, document.ContentEnd).Text .TrimEnd(' ', '\r', '\n', '\t').Replace("\r\n", "\n").Split('\n'); // try to parse, compile and link the current program code within a virtual core (not the real core!) var parser = new Parser(); parser.ParseFile(content); var linker = new Linker(new Memory(0x40000, 0x10000), parser); linker.CompileAndLink(); MessageBox.Show("Everything seems to be correct!", "Syntax Check"); } catch (Exception ex) { ErrorMessages.Add(ex.Message); } }