public TranslationUnit ParseTranslationUnit(Report report, string name, Preprocessor.Include include, params Token[][] tokens) { var preprocessor = new Preprocessor(include, report, tokens); lexer = new ParserInput(preprocessor.Preprocess()); _tu = new TranslationUnit(name); if (lexer.Tokens.Length == 0) { return(_tu); } try { yyparse(lexer); } catch (NotImplementedException err) { report.Error(9999, lexer.CurrentToken.Location, lexer.CurrentToken.EndLocation, "Not Supported: " + err.Message); } catch (NotSupportedException err) { report.Error(9001, lexer.CurrentToken.Location, lexer.CurrentToken.EndLocation, "Not Supported: " + err.Message); } catch (Exception err) when(err.Message == "irrecoverable syntax error") { report.Error(1001, lexer.CurrentToken.Location, lexer.CurrentToken.EndLocation, "Syntax error"); } catch (yyParser.yyUnexpectedEof) { report.Error(1513, lexer.CurrentToken.Location, lexer.CurrentToken.EndLocation, "Incomplete"); } catch (Exception err) { Debug.WriteLine(err); report.Error(9000, lexer.CurrentToken.Location, lexer.CurrentToken.EndLocation, "Parser Error: " + err.Message); } return(_tu); }