Ejemplo n.º 1
0
 internal Preprocessor(IVccUnpreprocessedSourceDocument documentToProcess, IDictionary<string, string> preprocessorDefinedSymbols, List<IErrorMessage> errors)
 {
     this.documentToProcess = documentToProcess;
       this.preprocessorDefinedSymbols = preprocessorDefinedSymbols;
       this.errors = errors;
       this.preprocessorInformation = new PreprocessorInformation(documentToProcess, errors);
       this.buffer = new char[8192];
 }
Ejemplo n.º 2
0
        private int startOfCurrentLine; //^ invariant 0 <= startOfCurrentLine && startOfCurrentLine <= fragmentIndex;

        #endregion Fields

        #region Constructors

        /// <summary>
        /// Allocates a preprocessor instance that can be queried for a list of source locations that represent the output from the preprocessor. This output
        /// omits preprocessor directives as well as any excluded sections. It also applies line directives by mapping some of the produced source locations
        /// onto the documents mentioned in the line directives. In other words, the produced source locations will not necessarily come from the document
        /// being preprocessed. Preprocessing happens lazily when the result of calling GetIncludedSections is enumerated.
        /// </summary>
        /// <param name="documentToProcess">The source document to preprocess.</param>
        /// <param name="options">An object that specifies any preprocessor symbols that are defined as compiler options by the environment.</param>
        internal Preprocessor(IVccUnpreprocessedSourceDocument documentToProcess, VccOptions options)
        {
            this.documentToProcess = documentToProcess;
              List<IErrorMessage> errors = this.errors = new List<IErrorMessage>();
              this.preprocessorInformation = new PreprocessorInformation(documentToProcess, errors);
              Dictionary<string, string> preprocessorDefinedSymbols = new Dictionary<string,string>();
              foreach (string ppOption in options.PreprocessorOptions) {
            if (!ppOption.StartsWith("/D", StringComparison.Ordinal)) continue;
            int eqIndex = ppOption.IndexOf('=');
            if (eqIndex < 0) eqIndex = ppOption.Length;
            string symName = ppOption.Substring(2, eqIndex-2);
            preprocessorDefinedSymbols[symName] = eqIndex != ppOption.Length ? ppOption.Substring(eqIndex+1) : String.Empty;
              }
              preprocessorDefinedSymbols["true"] = "true";
              preprocessorDefinedSymbols.Remove("false");
              this.preprocessorDefinedSymbols = preprocessorDefinedSymbols;
              this.buffer = new char[8192];
        }