private Dictionary <string, Macro> VerifyNoMetadata(string before, string after) { PreProcessorOptions opts = new PreProcessorOptions(); opts.FollowIncludes = true; return(VerifyImpl(opts, before, after)); }
private Dictionary <string, Macro> VerifyNormal(List <Macro> initialList, string before, string after) { PreProcessorOptions opts = new PreProcessorOptions(); opts.InitialMacroList.AddRange(initialList); opts.FollowIncludes = false; return(VerifyImpl(opts, before, after)); }
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); }
public void PoundInclude1() { string before = @"#include ""non_existent_file.h"""; string after = ""; var opts = new PreProcessorOptions() { FollowIncludes = true }; var map = VerifyImpl(opts, before, after); Assert.True(map.Count == 0); // include not found }
/// <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); } }
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); } } }