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

            if (_context.HasPreviousIfOrElif())
            {
                var branchTaken = endIsActive && !_context.PreviousBranchTaken();
                return(SyntaxFactory.ElseDirectiveTrivia(
                           hash,
                           keyword,
                           eod,
                           endIsActive,
                           branchTaken
                           ));
            }
            else if (_context.HasUnfinishedRegion())
            {
                return(this.AddError(
                           SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive),
                           ErrorCode.ERR_EndRegionDirectiveExpected
                           ));
            }
            else if (_context.HasUnfinishedIf())
            {
                return(this.AddError(
                           SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive),
                           ErrorCode.ERR_EndifDirectiveExpected
                           ));
            }
            else
            {
                return(this.AddError(
                           SyntaxFactory.BadDirectiveTrivia(hash, keyword, eod, isActive),
                           ErrorCode.ERR_UnexpectedDirective
                           ));
            }
        }