static void ParseEnumValue(TokenReader tr, ProtoEnum parent, string name) { if (tr.ReadNext() != "=") { throw new ProtoFormatException("Expected: =", tr); } int id = ParseInt(tr); var value = new ProtoEnumValue(name, id, lastComment); parent.Enums.Add(value); string extra = tr.ReadNext(); if (extra == ";") { return; } if (extra != "[") { throw new ProtoFormatException("Expected: ; or [", tr); } ParseEnumValueOptions(tr); }
static void ParseEnumValueOptions(TokenReader tr, ProtoEnumValue evalue) { while (true) { string key = tr.ReadNext(); tr.ReadNextOrThrow("="); string val = tr.ReadNext(); ParseEnumValueOptions(key, val, evalue); string optionSep = tr.ReadNext(); if (optionSep == "]") break; if (optionSep == ",") continue; throw new ProtoFormatException(@"Expected "","" or ""]"" got " + tr.NextCharacter, tr); } tr.ReadNextOrThrow(";"); }
static void ParseEnumValue(TokenReader tr, ProtoEnum parent, string name) { if (tr.ReadNext() != "=") throw new ProtoFormatException("Expected: =", tr); int id = int.Parse(tr.ReadNext()); var value = new ProtoEnumValue(name, id, lastComment); parent.Enums.Add(value); string extra = tr.ReadNext(); if (extra == ";") return; if (extra != "[") throw new ProtoFormatException("Expected: ; or [", tr); ParseEnumValueOptions(tr, value); }
static void ParseEnumValueOptions(string key, string val, ProtoEnumValue f) { //TODO }