public void TokenCallback(ParadoxParser parser, string token) { if (token != "id") throw new ApplicationException("Unrecognized token: " + token); if (parser.NextIsBracketed()) EventIds.Add(parser.Parse(new ParadoxId())); else EventNames.Add(parser.ReadString()); }
/// <summary> /// used to parse group options of the type: tag = { tag2 = data ... } /// </summary> /// <param name="tag">The *last* read tag.</param> /// <returns>Parsed option can be retrieved using GetLastRoot()</returns> public static void ParseGeneric(ParadoxParser parser, string tag) { Option opt; if (parser.NextIsBracketed()) { if (tag == "data") { opt = new IntListOption(tag, parser.ReadIntList()); } else { if (tag.Contains(".") && tag.IndexOf(".", StringComparison.Ordinal) != tag.LastIndexOf(".", StringComparison.Ordinal)) { opt = new EventOption(tag); } else { opt = new GroupOption(tag); } m_optionStack.Push(opt); parser.Parse(ParseGeneric); m_optionStack.Pop(); } } else { opt = ParseSingle(tag, parser.ReadString()); } if (m_optionStack.Count == 0) // We're in the root. { m_lastParsedOptionRoot = opt; } else { Option parent = m_optionStack.Peek(); if (parent.Type == OptionType.Group) { ((GroupOption)parent).SubOptions.Add(opt); } else if (parent.Type == OptionType.Event) { ((EventOption)parent).SubOptions.Add(opt); } } }
partial void unrecognizedToken(ParadoxParser parser, string token) { if (!parser.NextIsBracketed()) throw new ApplicationException("Unrecognized token: " + token); WarGoal = parser.Parse(new WarGoal(token)); }