StartLiteral() public method

Start parsing literal
public StartLiteral ( ) : void
return void
示例#1
0
        /// <summary>
        ///   Parses a String surrounded with single quotes
        /// </summary>
        private string ParseSingleQuoted(ParseStream stream)
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder();

            // Start literal parsing
            stream.StartLiteral();

            // Skip '''
            stream.Next(true);

            while (!stream.EOF)
            {
                if (stream.Char == '\'')
                {
                    stream.Next();

                    // Escaped single quote
                    if (stream.Char == '\'')
                    {
                        builder.Append(stream.Char);
                    }

                    // End of string
                    else
                    {
                        break;
                    }
                }
                else
                {
                    builder.Append(stream.Char);
                }

                stream.Next();

                // Skip \'
                if (stream.EOF)
                {
                    stream.StopLiteral();
                    throw new ParseException(stream,
                                             "Single quoted string not closed");
                }
            }

            // Stop literal parsing
            stream.StopLiteral();

            return(builder.ToString());
        }
        /// <summary>
        ///   Parses a String surrounded with single quotes
        /// </summary>
        private string ParseSingleQuoted(ParseStream stream)
        {
            System.Text.StringBuilder builder = new System.Text.StringBuilder ();

            // Start literal parsing
            stream.StartLiteral ();

            // Skip '''
            stream.Next (true);

            while (! stream.EOF)
            {
                if (stream.Char == '\'')
                {
                    stream.Next ();

                    // Escaped single quote
                    if (stream.Char == '\'')
                        builder.Append (stream.Char);

                        // End of string
                    else
                        break;
                }
                else
                    builder.Append (stream.Char);

                stream.Next ();

                // Skip \'
                if (stream.EOF)
                {
                    stream.StopLiteral ();
                    throw new ParseException (stream,
                        "Single quoted string not closed");
                }
            }

            // Stop literal parsing
            stream.StopLiteral ();

            return builder.ToString();
        }