public string Process(string line, IInputStream inputStream) { this.curLine.Stream = inputStream; this.curFile.Stream = inputStream; this.inputStream = inputStream; StringBuilder line1 = new StringBuilder(line); if (!Nintenlord.Utility.Strings.Parser.ReplaceCommentsWith(line1, ' ', ref this.blockCommentDepth)) { this.messageLog.AddError(inputStream.GetErrorString("Error removing comments")); } line = line1.ToString().Trim(); // foreach (string oldValue in this.predefined) // newLine = newLine.Replace(oldValue, " "); if (line.FirstNonWhiteSpaceIs('#')) { CanCauseError <string> canCauseError = this.defCol.ApplyPreprocessorDefines(line); if (!canCauseError.CausedError) { this.HandleDirective(canCauseError.Result); return(""); } else if (!this.include.And()) { return(""); } else { this.messageLog.AddError(inputStream.GetErrorString(canCauseError.ErrorMessage)); return(line); } } else { if (Program.RunConfig.ppSimulation) { return(""); } CanCauseError <string> customDefines = this.defCol.ApplyDefines(line); if (this.include.And() && !customDefines.CausedError) { string newLine = customDefines.Result; if (this.defCol.ContainsName("USING_CODE")) { newLine = Preprocessor.HandleCODE(newLine); } return(newLine); } else if (!this.include.And()) { return(""); } this.messageLog.AddError(inputStream.GetErrorString(customDefines.ErrorMessage)); return(line); } }
public string Process(string line, IInputStream inputStream) { curLine.Stream = inputStream; curFile.Stream = inputStream; this.inputStream = inputStream; StringBuilder lineModific = new StringBuilder(line); if (!Nintenlord.Utility.Strings.Parser.ReplaceCommentsWith(lineModific, ' ', ref blockCommentDepth)) { messageLog.AddError(inputStream.GetErrorString("Error removing comments")); } line = lineModific.ToString(); if (line.FirstNonWhiteSpaceIs('#')) { HandleDirective(line); return ""; } else { if (include.And()) { var newResult = defCol.ApplyDefines(line); if (!newResult.CausedError) { string newLine = newResult.Result; foreach (var item in predefined) { newLine = newLine.Replace(item, " "); } if (defCol.ContainsName("USING_CODE")) { newLine = HandleCODE(newLine); } return newLine; } else { messageLog.AddError(inputStream.GetErrorString(newResult.ErrorMessage)); return line; } } else { return ""; } } }