private void VerifyCount(string text, int errorCount, int warningCount)
        {
            PreProcessorEngine p = new PreProcessorEngine(new PreProcessorOptions());

            p.Process(new TextReaderBag("text", new StringReader(text)));
            Assert.Equal(errorCount, p.ErrorProvider.Errors.Count);
            Assert.Equal(warningCount, p.ErrorProvider.Warnings.Count);
        }
        private Dictionary <string, Macro> VerifyImpl(PreProcessorOptions opts, string before, string after)
        {
            PreProcessorEngine p      = new PreProcessorEngine(opts);
            string             actual = p.Process(new TextReaderBag("before", new StringReader(before)));

            Assert.Equal(after, actual);

            return(p.MacroMap);
        }
        private bool EvalCond(List <Macro> list, string cond)
        {
            string before            = "#if " + cond + PortConstants.NewLine + "true" + PortConstants.NewLine + "#else" + PortConstants.NewLine + "false" + PortConstants.NewLine + "#endif";
            PreProcessorOptions opts = new PreProcessorOptions();

            opts.InitialMacroList.AddRange(list);
            PreProcessorEngine engine = new PreProcessorEngine(opts);
            string             val    = engine.Process(new TextReaderBag("foo", new StringReader(before)));

            return(val.StartsWith("true"));
        }
        private Dictionary <string, Macro> VerifyMacro(string data, params string[] args)
        {
            PreProcessorOptions opts = new PreProcessorOptions();

            opts.FollowIncludes = false;
            PreProcessorEngine p = new PreProcessorEngine(opts);

            p.Process(new TextReaderBag("foo", new StringReader(data)));
            VerifyMap(p.MacroMap, args);
            return(p.MacroMap);
        }
示例#5
0
        /// <summary>
        /// Parse a data.  Import the sal semantics
        /// </summary>
        /// <returns></returns>
        /// <remarks></remarks>
        private ParseResult SalParse(string text)
        {
            string salText = File.ReadAllText("SampleFiles\\Sal.txt");
            text = salText + PortConstants.NewLine + text;

            PreProcessorOptions opts = new PreProcessorOptions();
            PreProcessorEngine pre = new PreProcessorEngine(opts);
            string data = pre.Process(new TextReaderBag(new StringReader(text)));
            string tempPath = Path.GetTempFileName();
            try
            {
                File.WriteAllText(tempPath, data);
                return ParseFile(tempPath);
            }
            finally
            {
                File.Delete(tempPath);
            }

        }
示例#6
0
        private ParseResult FullParseFile(string filePath)
        {
            PreProcessorOptions opts = new PreProcessorOptions();
            PreProcessorEngine pre = new PreProcessorEngine(opts);

            using (StreamReader stream = new StreamReader(filePath))
            {
                string data = pre.Process(new TextReaderBag(stream));
                string tempPath = Path.GetTempFileName();
                try
                {
                    File.WriteAllText(tempPath, data);
                    return ParseFile(tempPath);
                }
                finally
                {
                    File.Delete(tempPath);
                }
            }
        }