private FieldElement ParseField(
StringCollection wordList,
CodeAccess access,
MemberModifiers memberAttributes,
bool untypedAssignment)
{
FieldElement field = new FieldElement();
StringBuilder nameBuilder = new StringBuilder(DefaultWordLength);
foreach (string word in wordList)
{
string trimmedWord = word.Trim(' ', VBSymbol.AliasSeparator);
string upperWord = trimmedWord.ToUpperInvariant();
if ((!VBKeyword.IsVBKeyword(trimmedWord) ||
upperWord == VBKeyword.Custom.ToUpperInvariant() ||
upperWord == VBKeyword.Ansi.ToUpperInvariant() ||
upperWord == VBKeyword.Unicode.ToUpperInvariant() ||
upperWord == VBKeyword.Auto.ToUpperInvariant()) &&
trimmedWord.Length > 0)
{
nameBuilder.Append(trimmedWord);
nameBuilder.Append(VBSymbol.AliasSeparator);
nameBuilder.Append(' ');
}
}
field.Name = nameBuilder.ToString().TrimEnd(VBSymbol.AliasSeparator, ' ');
EatWhiteSpace();
if (!untypedAssignment)
{
string returnType = CaptureTypeName();
if (returnType.ToUpperInvariant() == VBKeyword.New.ToUpperInvariant())
{
EatWhiteSpace(WhiteSpaceTypes.SpaceAndTab);
field.InitialValue = VBKeyword.New + " " + ReadCodeLine().Trim();
}
else
{
field.Type = returnType;
}
}
field.Access = access;
field.MemberModifiers = memberAttributes;
EatWhiteSpace(WhiteSpaceTypes.SpaceAndTab);
bool isAssignment = NextChar == VBSymbol.Assignment || untypedAssignment;
if (isAssignment)
{
if (!untypedAssignment)
{
EatChar(VBSymbol.Assignment);
}
string initialValue = ParseInitialValue();
field.InitialValue = initialValue;
}
EatWhiteSpace(WhiteSpaceTypes.SpaceAndTab);
if (NextChar == VBSymbol.BeginComment)
{
EatChar(VBSymbol.BeginComment);
string commentText = ReadLine().Trim();
if (commentText.Length > 0)
{
CommentElement comment = new CommentElement(commentText);
field.TrailingComment = comment;
}
}
return field;
}