private List <CodePointer> getPointersFromMiniLine(CodePointer pointer, int lineIndex) { List <CodePointer> pointers = new List <CodePointer>(); CodePointer[] cmds = CodePointer.Split(pointer.Code, @":(\ |\t)*"); if (cmds == null || cmds.Length <= 0) { return(pointers); } List <CodePointer> tmps; CodePointer cp; string rep; string nextChar; for (int i = 0; i < cmds.Length; i++) { cmds[i].Move(pointer.Start); tmps = getPointersFromDefineSignature(cmds[i], lineIndex); if (tmps.Count > 0) { if (Define.possibleError != null) { tmps[1].Group = ErrorGroup; if (!errors.ContainsKey(lineIndex)) { errors.Add(lineIndex, new List <Error>()); } errors[lineIndex].Add(Define.possibleError); newErrors = true; } } if (tmps.Count <= 0) { rep = Define.Replace(defines, cmds[i].Code, lineIndex, cmds[i].Start); cp = new CodePointer { Start = cmds[i].Start, End = cmds[i].Start + rep.Length - 1, Code = rep }; tmps = getPointersFromCommands(cp); if (tmps.Count <= 0) { nextChar = ""; if (pointer.Code.Length + pointer.Start > cmds[i].End + 1 && pointer.Code[cmds[i].End - cmds[i].Start + 1] == ':') { nextChar = ":"; } tmps = getPointersFromLabels(cp, nextChar); } } if (tmps.Count <= 0) { tmps = new List <CodePointer>(); cmds[i].Group = ErrorGroup; tmps.Add(cmds[i]); if (!errors.ContainsKey(lineIndex)) { errors.Add(lineIndex, new List <Error>()); } errors[lineIndex].Add(new Error(lineIndex, cmds[i].Start, cmds[i].Code, ErrorCode.InvalidDefineSignature, cmds[i].Code)); newErrors = true; } foreach (CodePointer cp1 in tmps) { pointers.Add(cp1); } } return(pointers); }
public List <CodePointer> GetPointersFromLine(int lineIndex, string line) { List <CodePointer> pointers = new List <CodePointer>(); CodePointer cp = new CodePointer { Start = 0, End = line.Length - 1, Code = line, Group = DefaultGroup }; pointers.Add(cp); string[] splittedLine = line.Split(';'); if (splittedLine == null || splittedLine.Length <= 0) { return(pointers); } string lineCode = splittedLine[0]; string comment = line.Substring(lineCode.Length); Match stMatch = Regex.Match(lineCode, startPattern); if (stMatch.Success) { cp = new CodePointer { Start = stMatch.Index, End = stMatch.Index + stMatch.Length - 1, Code = stMatch.ToString(), Group = ErrorGroup }; pointers.Add(cp); newErrors = true; } else { stMatch = Regex.Match(lineCode, startSpaces); } string shorterLineCode = lineCode.Substring(stMatch.Length).Replace('\r', '\n').Replace("\n", ""); Match m = Regex.Match(shorterLineCode, endSpaces); if (m.Success) { int ll = shorterLineCode.Length - m.Length; if (ll < 0) { ll = 0; } shorterLineCode = shorterLineCode.Substring(0, ll); } CodePointer[] cmds = CodePointer.Split(shorterLineCode, separatorPattern); removeDefinesAtPosition(lineIndex); removeErrorsAtPosition(lineIndex); if (cmds != null && cmds.Length > 0) { List <CodePointer> tmps; for (int j = 0; j < cmds.Length; j++) { cmds[j].Move(stMatch.Length); tmps = getPointersFromMiniLine(cmds[j], lineIndex); foreach (CodePointer cp1 in tmps) { pointers.Add(cp1); } } } Match endMatch = Regex.Match(lineCode, endPattern); if (endMatch.Success) { cp = new CodePointer { Start = endMatch.Index, End = endMatch.Index + endMatch.Length - 1, Code = endMatch.ToString(), Group = ErrorGroup }; pointers.Add(cp); newErrors = true; } cp = new CodePointer { Start = lineCode.Length, End = line.Length - 1, Code = comment, Group = CommentGroup }; pointers.Add(cp); return(pointers); }