private void ScanMultiLineString(LineProgress p)
        {
            bool markText = !this.IgnoreVerbatimStrings;

            if (markText)
            {
                p.StartNaturalText();
            }

            while (!p.EndOfLine)
            {
                if (p.Char() == '"' && p.NextChar() == '"') // "" is allowed within multi-line string.
                {
                    p.Advance(2);
                }
                else if (p.Char() == '"') // End of multi-line string
                {
                    if (markText)
                    {
                        p.EndNaturalText();
                    }

                    p.Advance();
                    p.State = State.Default;
                    return;
                }
                else
                {
                    p.Advance();
                }
            }

            // End of line.  Emit as human readable, but remain in MultiLineString state.
            if (markText)
            {
                p.EndNaturalText();
            }

            Debug.Assert(p.State == State.MultiLineString);
        }
        private static void ScanDocCommentXmlString(LineProgress p)
        {
            while (!p.EndOfLine)
            {
                if (p.Char() == '"')
                {
                    p.Advance(1);
                    p.State = State.DocCommentXml;

                    return; // Done with string in doc comment XML.
                }

                p.Advance();
            }

            // End of line.  Never found the '"' to close the string, but whatever.  We revert to default state.
            p.State = State.Default;
        }
        private void ScanDefault(LineProgress p)
        {
            while (!p.EndOfLine)
            {
                if (p.Char() == '/' && p.NextChar() == '/' && p.NextNextChar() == '/') // Doc comment
                {
                    p.Advance(3);

                    if (this.IgnoreXmlDocComments && (p.EndOfLine || p.Char() != '/'))
                    {
                        p.AdvanceToEndOfLine();
                        return;
                    }

                    if (this.IgnoreQuadrupleSlashComments && !p.EndOfLine && p.Char() == '/')
                    {
                        p.AdvanceToEndOfLine();
                        return;
                    }

                    p.State = State.DocComment;
                    ScanDocComment(p);
                }
                else if (p.Char() == '/' && p.NextChar() == '/') // Single line comment
                {
                    p.Advance(2);

                    if (!this.IgnoreStandardSingleLineComments)
                    {
                        p.StartNaturalText();
                        p.AdvanceToEndOfLine();
                        p.EndNaturalText();
                    }
                    else
                    {
                        p.AdvanceToEndOfLine();
                    }

                    p.State = State.Default;
                    return;
                }
                else if (p.Char() == '/' && p.NextChar() == '*') // Multi-line comment or multi-line doc comment
                {
                    p.Advance(2);

                    // "/***" is just a regular multi-line comment, not a doc comment
                    if (p.EndOfLine || p.Char() != '*' || p.NextChar() == '*')
                    {
                        p.State = State.MultiLineComment;
                        ScanMultiLineComment(p);
                    }
                    else
                    {
                        p.State = State.MultiLineDocComment;
                        ScanMultiLineDocComment(p);
                    }
                }
                else if (p.Char() == '@' && p.NextChar() == '"') // Verbatim string
                {
                    p.Advance(2);
                    p.State = State.MultiLineString;
                    ScanMultiLineString(p);
                }
                else if (p.Char() == '"') // Single-line string
                {
                    p.Advance(1);
                    p.State = State.String;
                    ScanString(p);
                }
                else if (p.Char() == '\'') // Character literal
                {
                    p.Advance(1);
                    p.State = State.Character;
                    ScanCharacter(p);
                }
                else if (p.Char() == '#')    // Possible preprocessor keyword, check for #region
                {
                    p.Advance(1);

                    // If found, treat it like a single line comment
                    if (p.NextSegment(6) == "region")
                    {
                        p.StartNaturalText();
                        p.AdvanceToEndOfLine();
                        p.EndNaturalText();

                        p.State = State.Default;
                        return;
                    }
                }
                else
                {
                    p.Advance();
                }
            }
        }