Exemplo n.º 1
0
        private DirectiveTriviaSyntax ParseEndIfDirective(
            SyntaxToken hash,
            SyntaxToken keyword,
            bool isActive,
            bool endIsActive
            )
        {
            var eod = this.ParseEndOfDirective(ignoreErrors: false);

            if (_context.HasUnfinishedIf())
            {
                return(SyntaxFactory.EndIfDirectiveTrivia(hash, keyword, eod, endIsActive));
            }
            else if (_context.HasUnfinishedRegion())
            {
                // CONSIDER: dev10 actually pops the region off the directive stack here.
                // See if (tok == PPT_ENDIF) in CSourceData::CPreprocessor::ScanPreprocessorIfSection.
                return(this.AddError(
                           SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive),
                           ErrorCode.ERR_EndRegionDirectiveExpected
                           ));
            }
            else
            {
                return(this.AddError(
                           SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive),
                           ErrorCode.ERR_UnexpectedDirective
                           ));
            }
        }