示例#1
0
        private SyntaxToken ParseEndOfDirectiveWithOptionalPreprocessingMessage()
        {
            StringBuilder builder = null;

            if (this.CurrentToken.Kind != SyntaxKind.EndOfDirectiveToken &&
                this.CurrentToken.Kind != SyntaxKind.EndOfFileToken)
            {
                builder = new StringBuilder(this.CurrentToken.FullWidth);

                while (this.CurrentToken.Kind != SyntaxKind.EndOfDirectiveToken &&
                       this.CurrentToken.Kind != SyntaxKind.EndOfFileToken)
                {
                    var token = this.EatToken();

                    builder.Append(token.ToFullString());
                }
            }

            SyntaxToken endOfDirective = this.CurrentToken.Kind == SyntaxKind.EndOfDirectiveToken
                                         ? this.EatToken()
                                         : SyntaxFactory.Token(SyntaxKind.EndOfDirectiveToken);

            if (builder != null)
            {
                endOfDirective = endOfDirective.TokenWithLeadingTrivia(
                    SyntaxFactory.PreprocessingMessage(builder.ToString()));
            }

            return(endOfDirective);
        }