Inheritance: MessageEnumBase
Exemplo n.º 1
0
        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: ;");
            }
        }