Ejemplo n.º 1
0
        private DirectiveTriviaSyntax ParseDefineOrUndefDirective(
            SyntaxToken hash,
            SyntaxToken keyword,
            bool isActive,
            bool isFollowingToken
            )
        {
            if (isFollowingToken)
            {
                keyword = this.AddError(keyword, ErrorCode.ERR_PPDefFollowsToken);
            }

            var name = this.EatToken(SyntaxKind.IdentifierToken, ErrorCode.ERR_IdentifierExpected);

            name = TruncateIdentifier(name);
            var end = this.ParseEndOfDirective(ignoreErrors: name.IsMissing);

            if (keyword.Kind == SyntaxKind.DefineKeyword)
            {
                return(SyntaxFactory.DefineDirectiveTrivia(hash, keyword, name, end, isActive));
            }
            else
            {
                return(SyntaxFactory.UndefDirectiveTrivia(hash, keyword, name, end, isActive));
            }
        }