private void Parse(Stream stream) { modes.Push(Mode.ScanForEnum); using (var reader = new StreamReader(stream)) { string line; while ((line = reader.ReadLine()) != null) { handlers[modes.Peek()](line); } } foreach (var group in groupedRegisters) { var widths = group.Value.Select(x => x.Item1.Width).Distinct().ToList(); if (widths.Count != 1) { // we found at least two registers having index with the same name, but different width throw new ArgumentException(string.Format("Inconsistent register width detected for group: {0}", group.Key)); } var groupDescriptor = new RegisterGroupDescriptor { Name = group.Key, Width = widths.First(), IndexValueMap = new Dictionary <int, int>() }; foreach (var x in group.Value.Select(x => Tuple.Create(x.Item2, x.Item1.Value))) { groupDescriptor.IndexValueMap.Add(x.Item1, x.Item2); } registerGroups.Add(groupDescriptor); } }
private void Parse(Stream stream) { modes.Push(Mode.ScanForEnum); using(var reader = new StreamReader(stream)) { string line; while((line = reader.ReadLine()) != null) { handlers[modes.Peek()](line); } } foreach(var group in groupedRegisters) { var widths = group.Value.Select(x => x.Item1.Width).Distinct().ToList(); if(widths.Count != 1) { // we found at least two registers having index with the same name, but different width throw new ArgumentException(string.Format("Inconsistent register width detected for group: {0}", group.Key)); } var groupDescriptor = new RegisterGroupDescriptor { Name = group.Key, Width = widths.First(), IndexValueMap = new Dictionary<int, int>() }; foreach(var x in group.Value.Select(x => Tuple.Create(x.Item2, x.Item1.Value))) { groupDescriptor.IndexValueMap.Add(x.Item1, x.Item2); } registerGroups.Add(groupDescriptor); } }