Beispiel #1
0
        /// <summary>
        /// Build a character constant from a double qouted string.
        /// </summary>
        /// <remarks>
        /// The leading and trailing double qoutes will be removed.
        /// </remarks>
        /// <param name="text">The text constant.</param>
        /// <returns>Returns an <see cref="AST.Constant"/> with a <see cref="ConstantType.CharacterConstant"/>.</returns>
        public static Constant DoubleQuotedConstant(string text)
        {
            // Remove the leading and trailing double quotes (if there is any)
            string processedText = (text.StartsWith("\"") && text.EndsWith("\""))
                ? text.Substring(1, text.Length - 2)
                : text;

            return(new Constant(StringProcessor.ProcessEscapes(processedText), ConstantType.CharacterConstant));
        }