public static SourceDocument Parse(string sourceCode) { var errorSink = new ErrorSink(); var lexer = new Lexer.Lexer(errorSink); var parser = new Parser(errorSink); var src = new SourceCode(sourceCode); var tokens = lexer.LexFile(src).ToArray(); if (errorSink.HasErrors) { errorSink.ConsolePrint(); return(null); } var sourceDoc = parser.ParseFile(src, tokens); if (errorSink.HasErrors) { errorSink.ConsolePrint(); return(null); } return(sourceDoc); }