Example #1
0
        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);
            }
        }