ProtocolBuffers.ProtoParser.ParseEnum C# (CSharp) Method

ParseEnum() static private method

static private ParseEnum ( TokenReader tr, Message parent ) : MessageEnum
tr TokenReader
parent Message
return MessageEnum
        static MessageEnum ParseEnum(TokenReader tr, Message parent)
        {
            MessageEnum me = new MessageEnum (parent);
            me.Comments = lastComment;
            lastComment = null;
            me.ProtoName = tr.ReadNext ();

            if (tr.ReadNext () != "{")
                throw new ProtoFormatException ("Expected: {");

            while (true) {
                string name = tr.ReadNext ();

                if (ParseComment (name))
                    continue;

                if (name == "}")
                    return me;

                //Ignore options
                if (name == "option") {
                    ParseOption (tr, null);
                    lastComment = null;
                    continue;
                }

                if (tr.ReadNext () != "=")
                    throw new ProtoFormatException ("Expected: =");

                int id = int.Parse (tr.ReadNext ());

                me.Enums.Add (name, id);
                if (lastComment != null)
                    me.EnumsComments.Add (name, lastComment);
                lastComment = null;

                if (tr.ReadNext () != ";")
                    throw new ProtoFormatException ("Expected: ;");
            }
        }