private void field_or_method_declaration(ref ClassTypeNode currentClassType, TypeNode type, EncapsulationNode encapsulation, MethodModifierNode modifier) { printIfDebug("field_or_method_declaration"); if (!pass(TokenType.ID)) { throwError("identifier expected"); } var Identifier = new IdNode(token.lexeme, token); var identifierMethodOrFielToken = token; consumeToken(); if (pass(TokenType.PUNT_PAREN_OPEN)) { var newMethodDeclared = method_declaration(Identifier, type, identifierMethodOrFielToken); newMethodDeclared.setEncapsulation(encapsulation); if (modifier != null) { newMethodDeclared.setModifier(modifier); } currentClassType.addMethod(newMethodDeclared); } else { var isStatic = (modifier != null)?modifier.token.type == TokenType.RW_STATIC:false; if (modifier != null && !isStatic) { Utils.ThrowError("The modifier '" + modifier.token.lexeme + "' is not valid on fields. Try using a property instead."); } var fieldDeclarationList = field_declaration(type, Identifier, encapsulation, isStatic); currentClassType.addFields(fieldDeclarationList); } }