Npgsql.NpgsqlCommand.GetDistinctTrimmedCommands C# (CSharp) Method

GetDistinctTrimmedCommands() private static method

Find the beginning and end of each distinct SQL command and produce a list of descriptors, one for each command. Commands described are trimmed of leading and trailing white space and their terminating semi-colons.
private static GetDistinctTrimmedCommands ( string src ) : StringChunk[]
src string Raw command text.
return StringChunk[]
        private static StringChunk[] GetDistinctTrimmedCommands(string src)
        {
            bool inQuote = false;
            bool quoteEscape = false;
            int currCharOfs = -1;
            int currChunkBeg = 0;
            int currChunkRawLen = 0;
            int currChunkTrimLen = 0;
            List<StringChunk> chunks = new List<StringChunk>();

            foreach (char ch in src)
            {
                currCharOfs++;

                // goto label for character re-evaluation:
                ProcessCharacter:

                if (! inQuote)
                {
                    switch (ch)
                    {
                        case '\'' :
                            inQuote = true;

                            currChunkRawLen++;
                            currChunkTrimLen = currChunkRawLen;

                            break;

                        case ';' :
                            if (currChunkTrimLen > 0)
                            {
                                chunks.Add(new StringChunk(currChunkBeg, currChunkTrimLen));
                            }

                            currChunkBeg = currCharOfs + 1;
                            currChunkRawLen = 0;
                            currChunkTrimLen = 0;

                            break;

                        case ' ' :
                        case '\t' :
                        case '\r' :
                        case '\n' :
                            if (currChunkTrimLen == 0)
                            {
                                currChunkBeg++;
                            }
                            else
                            {
                                currChunkRawLen++;
                            }

                            break;

                        default :
                            currChunkRawLen++;
                            currChunkTrimLen = currChunkRawLen;

                            break;

                    }
                }
                else
                {
                    switch (ch)
                    {
                        case '\'' :
                            if (quoteEscape)
                            {
                                quoteEscape = false;
                            }
                            else
                            {
                                quoteEscape = true;
                            }

                            currChunkRawLen++;
                            currChunkTrimLen = currChunkRawLen;

                            break;

                        default :
                            if (quoteEscape)
                            {
                                quoteEscape = false;
                                inQuote = false;

                                // Re-evaluate this character
                                goto ProcessCharacter;
                            }
                            else
                            {
                                currChunkRawLen++;
                                currChunkTrimLen = currChunkRawLen;
                            }

                            break;

                    }
                }
            }

            if (currChunkTrimLen > 0)
            {
                chunks.Add(new StringChunk(currChunkBeg, currChunkTrimLen));
            }

            return chunks.ToArray();
        }