private DatObject ParseObject() { var datObject = new DatObject(); Token curToken = Token.Property; while (curToken != Token.None) { if (ReadIndex >= Content.Length) { break; } var chr = Content[ReadIndex]; ReadIndex++; CurrentLinePos++; if (chr == '\n') { CurrentLinePos = 0; CurrentLine++; continue; } if (chr == '\r') { continue; } var whiteSpace = char.IsWhiteSpace(chr); if (whiteSpace) { continue; } if (chr == ')') { break; } ReadIndex--; datObject.Properties.Add(ParseProperty()); } return(datObject); }
private DatGame ParseGame(DatObject datObj) { if (datObj == null) { throw new ArgumentNullException("Can't parse game object, no object given."); } var datGame = new DatGame(); foreach (var prop in datObj.Properties) { var romAdded = false; if (prop.Name == "rom" && !romAdded) { romAdded = true; foreach (var romDatProp in (prop.Value as DatObject).Properties) { if (datGameProperties.TryGetValue("rom." + romDatProp.Name, out var romPropInfo)) { SetParsedProperty(romPropInfo, datGame, (string)romDatProp.Value); } } } else if (datGameProperties.TryGetValue(prop.Name, out var propInfo)) { if (prop.Value is DatObject) { throw new Exception("Can't assign object to uknown dat property."); } SetParsedProperty(propInfo, datGame, (string)prop.Value); } } datGame.FixData(); return(datGame); }