private string PreProcessLine(string lineToProcess) { if (DeletingCurrentLine()) { return string.Empty; } Stack<StringBuilder> previousOutput = new Stack<StringBuilder>(); Stack<FastString> previousLine = new Stack<FastString>(); StringBuilder output = new StringBuilder(lineToProcess.Length); FastString line = new FastString(lineToProcess); Stack<String> ignored = new Stack<String>(); while (line.Length > 0) { int i = 0; while ((i < line.Length) && (!Char.IsLetterOrDigit(line[i]))) { if ((line[i] == '"') || (line[i] == '\'')) { i = FindIndexOfMatchingCharacter(line.ToString(), i, line[i]); if (i < 0) { i = line.Length; break; } } i++; } output.Append(line.Substring(0, i)); if (i < line.Length) { bool precededByDot = false; if (i > 0) precededByDot = (line[i - 1] == '.'); line = line.Substring(i); string realStringLine = line.ToString(); string theWord = GetNextWord(ref realStringLine, false, false); line = realStringLine; if ((!precededByDot) && (!ignored.Contains(theWord)) && (_state.Macros.Contains(theWord))) { previousOutput.Push(output); previousLine.Push(line); ignored.Push(theWord); line = new FastString(_state.Macros[theWord]); output = new StringBuilder(line.Length); } else { output.Append(theWord); } } else line = ""; while (line.Length == 0 && previousOutput.Count > 0) { String result = output.ToString(); output = previousOutput.Pop(); line = previousLine.Pop(); ignored.Pop(); output.Append(result); } } return output.ToString(); }
private string PreProcessLine(string lineToProcess) { if (DeletingCurrentLine()) { return string.Empty; } StringBuilder output = new StringBuilder(lineToProcess.Length); FastString line = new FastString(lineToProcess); while (line.Length > 0) { int i = 0; while ((i < line.Length) && (!Char.IsLetterOrDigit(line[i]))) { if ((line[i] == '"') || (line[i] == '\'')) { i = FindIndexOfMatchingCharacter(line.ToString(), i, line[i]); if (i < 0) { i = line.Length; break; } } i++; } output.Append(line.Substring(0, i)); if (i >= line.Length) { break; } bool precededByDot = false; if (i > 0) precededByDot = (line[i - 1] == '.'); line = line.Substring(i); string realStringLine = line.ToString(); string theWord = GetNextWord(ref realStringLine, false, false); line = realStringLine; if ((!precededByDot) && (_state.Macros.Contains(theWord))) { output.Append(_state.Macros[theWord]); } else { output.Append(theWord); } } return output.ToString(); }
private string PreProcessLine(string lineToProcess) { if (DeletingCurrentLine()) { return(string.Empty); } Stack <StringBuilder> previousOutput = new Stack <StringBuilder>(); Stack <FastString> previousLine = new Stack <FastString>(); StringBuilder output = new StringBuilder(lineToProcess.Length); FastString line = new FastString(lineToProcess); Stack <String> ignored = new Stack <String>(); while (line.Length > 0) { int i = 0; while ((i < line.Length) && (!Char.IsLetterOrDigit(line[i]))) { if ((line[i] == '"') || (line[i] == '\'')) { i = FindIndexOfMatchingCharacter(line.ToString(), i, line[i]); if (i < 0) { i = line.Length; break; } } i++; } output.Append(line.Substring(0, i)); if (i < line.Length) { bool precededByDot = false; if (i > 0) { precededByDot = (line[i - 1] == '.'); } line = line.Substring(i); string realStringLine = line.ToString(); string theWord = GetNextWord(ref realStringLine, false, false); line = realStringLine; if ((!precededByDot) && (!ignored.Contains(theWord)) && (_state.Macros.Contains(theWord))) { previousOutput.Push(output); previousLine.Push(line); ignored.Push(theWord); line = new FastString(_state.Macros[theWord]); output = new StringBuilder(line.Length); } else { output.Append(theWord); } } else { line = ""; } while (line.Length == 0 && previousOutput.Count > 0) { String result = output.ToString(); output = previousOutput.Pop(); line = previousLine.Pop(); ignored.Pop(); output.Append(result); } } return(output.ToString()); }