private void Scan(string str, int start) { int pos = str.IndexOfAny(sDelimiters, start); if (pos < 0) { return; } switch (str[pos]) { case '{': string title = str.Substring(start, pos - start).Trim(); if (IsProtocol(title)) { mCurrentProtocol = NewProtocol(title); } else { mLastType = mCurrentType; mCurrentType = NewType(title); } break; case '}': if (mCurrentType != null) { mListener.OnNewType(mCurrentType); if (mCurrentProtocol != null) { mCurrentProtocol.AddType(mCurrentType); } mCurrentType = mLastType; mLastType = null; } else if (mCurrentProtocol != null) { mListener.OnNewProtocol(mCurrentProtocol); mCurrentProtocol = null; } break; case '\n': SpField f = NewField(str.Substring(start, pos - start)); if (f != null && mCurrentType != null) { mCurrentType.AddField(f); } break; } start = pos + 1; Scan(str, start); }