예제 #1
0
 public void AddError(string msg)
 {
     _errorProvider.AddError(GetMessagePrefix() + msg);
 }
예제 #2
0
        /// <summary>
        /// Core processing loop.  Processes blocks of text.
        /// </summary>
        /// <remarks></remarks>

        private void ProcessLoop()
        {
            bool done = false;

            while (!done)
            {
                ScannerMark mark = _scanner.Mark();

                try
                {
                    PreprocessorLine line = this.GetNextLine();
                    ThrowIfFalse(line.TokenList.Count > 0);

                    Token token = line.FirstValidToken;
                    if (token == null)
                    {
                        WriteToStream(line);
                        continue;
                    }

                    switch (token.TokenType)
                    {
                    case TokenType.PoundIf:
                        ProcessPoundIf(line);
                        break;

                    case TokenType.PoundIfndef:
                        ProcessPoundIfndef(line);
                        break;

                    case TokenType.PoundElse:
                    case TokenType.PoundElseIf:
                        // stop on a conditional branch end
                        ChewThroughConditionalEnd();
                        done = true;
                        break;

                    case TokenType.EndOfStream:
                    case TokenType.PoundEndIf:
                        done = true;
                        break;

                    case TokenType.PoundPragma:
                        ProcessPoundPragma(line);
                        break;

                    case TokenType.PoundDefine:
                        ProcessPoundDefine(line);
                        break;

                    case TokenType.PoundUnDef:
                        ProcessPoundUndefine(line);
                        break;

                    case TokenType.PoundInclude:
                        ProcessPoundInclude(line);
                        break;

                    default:
                        WriteToStream(line);
                        break;
                    }
                }
                catch (PreProcessorException ex)
                {
                    if (ex.IsError)
                    {
                        _errorProvider.AddError(ex.Message);
                    }
                    else
                    {
                        _errorProvider.AddWarning(ex.Message);
                    }
                    _scanner.Rollback(mark);
                    GetNextLine();
                    // Chew through the line
                }
            }
        }