public CompilationUnitSyntax Parse(ITokenIterator tokens) { var implicitNamespaceName = ParseImplicitNamespaceName(tokens); var parser = new Parser(tokens, implicitNamespaceName); var usingDirectives = parser.ParseUsingDirectives(); var declarations = parser.ParseTopLevelDeclarations(); tokens.Required <IEndOfFileToken>(); return(new CompilationUnitSyntax(tokens.Context.File, implicitNamespaceName, usingDirectives, declarations, tokens.Context.Diagnostics.Build())); }
public ICompilationUnitSyntax Parse(ITokenIterator <IEssentialToken> tokens) { var implicitNamespaceName = ParseImplicitNamespaceName(tokens); var parser = new Parser(tokens, implicitNamespaceName); var usingDirectives = parser.ParseUsingDirectives(); var declarations = parser.ParseNonMemberDeclarations <IEndOfFileToken>(); var eof = tokens.Required <IEndOfFileToken>(); var span = TextSpan.FromStartEnd(0, eof.End); var diagnostics = tokens.Context.Diagnostics; var compilationUnit = new CompilationUnitSyntax(implicitNamespaceName, span, tokens.Context.File, usingDirectives, declarations); CheckSyntax(compilationUnit, diagnostics); compilationUnit.Attach(diagnostics.Build()); return(compilationUnit); }