public void LoadInstructionMap(IEnumerable <string> s) { IEnumerator <string> lines = s.GetEnumerator(); if (!lines.MoveNext()) { return; // empty file? } string instructionString; while (!string.IsNullOrEmpty(instructionString = lines.Current)) { if (!lines.MoveNext()) { return; // should probably throw an exception } var instruction = ASMInstructionTemplate.Parse(instructionString); instructionMap.Add(instruction); while (lines.Current.StartsWith(" ")) { instruction.AddNativeInstructionTemplate(lines.Current.Substring(2)); if (!lines.MoveNext()) { return; // no newline on EOF :( } } } }
public static ASMInstructionTemplate Parse(string str) { var ret = new ASMInstructionTemplate(); string[] split = str.Split(' '); ret.Token = split[0]; int i = 0; var paramList = new List <ASMParameterTemplate>(); while (split[++i][0] != '(') { paramList.Add(ASMParameterTemplate.Parse(split[i])); } ret.Delay = split[i][1] - '0'; ret.IsGeneric = split[split.Length - 1].Equals("generic"); ret.parameter = paramList.ToArray(); return(ret); }