public MakeClass AddMethodsAndFields(LexList list, bool overwriteAllowed) { if (InputList != null) { PreviousInputLists.Add(InputList); } InputList = list; Type varType = null; var currentListOfMethods = new List <CompileMethod>(); try { Crosslink(); DoClassVisibility(); DoClassType(); InputList.CheckStrAndAdvance("{", "Expected an { after the class header."); while (true) { if (InputList.Str == "}" && InputList.NextIsAtEnd()) { break; } else if ((InputList.Str == "public" || InputList.Str == "private" || InputList.Str == "[") && !IsAFieldDefinition()) { CompileNextMethodHeader(InputList, overwriteAllowed, currentListOfMethods); } else if ((InputList.Str == "public" || InputList.Str == "private") && IsAFieldDefinition()) { InputList.Next(); varType = IsVarKind(); if (varType == null) { InputList.ThrowException("Unknown field type here"); } CompileNextFieldDefinition(InputList, varType); } else if ((varType = IsVarKind()) != null) { CompileNextFieldDefinition(InputList, varType); } else { InputList.ThrowException("Expected either a 'public' or 'private' keyword (to start a method) or a type (to start a field declaration) here or the closing } of the class."); } } InputList.CheckStrAndAdvance("}", "Expected a closing } here."); if (!InputList.AtEnd()) { InputList.ThrowException("Expected the end of the source text here."); } if (MadeFieldsDict.Count > 0) { MakeFieldInitialiser(currentListOfMethods); } FinishClass(currentListOfMethods); } catch (LexListException lle) { throw lle; } catch (Exception ex) { list.CurrentToken().ThrowException(ex.Message, list); } return(this); }