/// <summary>
        /// Take the given text and treat it as the contents of a string literal, returning a token for that.
        /// </summary>
        /// <param name="text">The text for the full string literal, including the quotes and contents</param>
        /// <param name="kind">The token kind to be assigned to the resulting token</param>
        SyntaxToken MakeStringToken(string text, SyntaxKind kind)
        {
            int length        = text.Length;
            int startingChars = (length > 2 && text[0] == '"' || length > 1 && text[0] == '}') ? 1 : 0;
            int endingChars   = (length > 1 && text[length - 1] == '"') ? 1 : (length > 2 && text[length - 1] == '{' && text[length - 2] == '\\') ? 2 : 0;

            using (var tempLexer = new Lexer(Text.SourceText.From("\"" + text.Substring(startingChars, length - startingChars - endingChars) + "\""), this.Options))
            {
                var info = default(Lexer.TokenInfo);
                tempLexer.ScanStringLiteral(ref info);
                Debug.Assert(info.Kind == SyntaxKind.StringLiteralToken);
                return(SyntaxFactory.Literal(null, text, kind, info.StringValue, null));
            }
        }
Example #2
0
            private void ScanInterpolatedStringLiteralNestedString()
            {
                var discarded = default(TokenInfo);

                lexer.ScanStringLiteral(ref discarded, true);
            }
Example #3
0
            private void ScanInterpolatedStringLiteralNestedString()
            {
                var discarded = default(TokenInfo);

                _lexer.ScanStringLiteral(ref discarded, inDirective: false);
            }