PreviousBranchTaken() public method

public PreviousBranchTaken ( ) : bool
return bool
Example #1
0
        private DirectiveTriviaSyntax ParseElseDirective(SyntaxToken hash, SyntaxToken keyword, bool isActive, bool endIsActive)
        {
            var eod = ParseEndOfDirective(false);

            if (_directiveStack.HasPreviousIfOrElif())
            {
                var branchTaken = endIsActive && !_directiveStack.PreviousBranchTaken();
                return(new ElseDirectiveTriviaSyntax(
                           hash,
                           keyword,
                           eod,
                           endIsActive, branchTaken));
            }

            if (_directiveStack.HasUnfinishedIf())
            {
                return(WithDiagnostic(new BadDirectiveTriviaSyntax(hash, keyword, eod, isActive), DiagnosticId.EndIfDirectiveExpected, $"Expected #endif directive"));
            }

            return(WithDiagnostic(new BadDirectiveTriviaSyntax(hash, keyword, eod, isActive), DiagnosticId.UnexpectedDirective, $"Unexpected directive: '{keyword}'"));
        }