Beispiel #1
0
        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);
        }