private string TryParseImplementsOrHandles(
out string[] implements, out string[] handles, bool parseHandles)
{
EatWhiteSpace();
List<string> aliasList = new List<string>();
StringBuilder read = new StringBuilder(DefaultBlockLength);
EatLineContinuation(read);
bool implementsRead = false;
bool handlesRead = false;
if (char.ToLower(NextChar) == char.ToLower(VBKeyword.Implements[0]))
{
foreach (char ch in VBKeyword.Implements.ToCharArray())
{
if (char.ToLower(NextChar) == char.ToLower(ch))
{
TryReadChar();
read.Append(CurrentChar);
implementsRead = true;
}
else
{
implementsRead = false;
break;
}
}
}
else if (parseHandles && char.ToLower(NextChar) == char.ToLower(VBKeyword.Handles[0]))
{
foreach (char ch in VBKeyword.Handles.ToCharArray())
{
if (char.ToLower(NextChar) == char.ToLower(ch))
{
TryReadChar();
read.Append(CurrentChar);
handlesRead = true;
}
else
{
handlesRead = false;
break;
}
}
}
if (implementsRead || handlesRead)
{
do
{
EatLineContinuation(read);
if (aliasList.Count > 0 && NextChar == VBSymbol.AliasSeparator)
{
TryReadChar();
}
string alias = CaptureTypeName();
if (string.IsNullOrEmpty(alias))
{
if (implementsRead)
{
this.OnParseError("Expected an interface member name.");
}
else
{
this.OnParseError("Expected an event name.");
}
}
else if (read.Length > 0 && read[read.Length - 1] == VBSymbol.LineContinuation)
{
//
// This is the scenario where the identifier starts
// with an underscore.
//
alias = VBSymbol.LineContinuation.ToString() + alias;
}
aliasList.Add(alias);
read = new StringBuilder(DefaultBlockLength);
EatLineContinuation(read);
} while (NextChar == VBSymbol.AliasSeparator);
}
implements = new string[] {};
handles = new string[] {};
if (implementsRead)
{
implements = aliasList.ToArray();
}
else if (handlesRead)
{
handles = aliasList.ToArray();
}
return read.ToString();
}