protected void Preprocess(StringReader reader, string path)
        {
            string line;
            int    lineNumber = 1;

            while ((line = reader.ReadLine()) != null)
            {
                int           amonutOfLinesRead = 1;
                List <string> splitLine         = new List <string>(line.Split(parameterSeparators, uniters));
                if (splitLine.Count > 0)
                {
                    if (splitLine[0][0] == '#')
                    {
                        string newLine;
                        while (splitLine.Last().EndsWith("/") && (newLine = reader.ReadLine()) != null)
                        {
                            line += newLine;
                            splitLine.AddRange(newLine.Split(parameterSeparators, uniters));
                            amonutOfLinesRead++;
                        }

                        PreprocessorDirective(line, splitLine[0].Substring(1), splitLine.ToArray().GetRange(1),
                                              path, lineNumber);
                    }
                    else if (line.Length > 0 && include.And())
                    {
                        if (!defCol.ApplyDefines(line, out line))//do define replacement
                        {
                            messageLog.AddError(path, line, "Error applying defines or macros.");
                        }
                        //Replace _line_ and _file_
                        line = line.Replace(lineDefine, lineNumber.ToString());
                        line = line.Replace(fileDefine, "\"" + path + "\"");
                        foreach (string item in predefined)
                        {
                            line = line.Replace(item, " ");
                        }
                        output.AppendLine(line);
                    }
                }
                lineNumber += amonutOfLinesRead;
            }
        }
Beispiel #2
0
 private void ApplyDefines(ref string text, int lineNumber, string file, IDefineCollection defCol)
 {
     defCol.ApplyDefines(text, out text);
     text = text.Replace(Preprocessor.lineNumber, lineNumber.ToString());
     text = text.Replace(Preprocessor.fileName, "\"" + file + "\"");
 }
 private void ApplyDefines(ref string text, int lineNumber, string file, IDefineCollection defCol)
 {
     defCol.ApplyDefines(text, out text);
     text = text.Replace(Preprocessor.lineNumber, lineNumber.ToString());
     text = text.Replace(Preprocessor.fileName, "\"" + file + "\"");
 }