public Parse ( string file ) : SlimDX.Generator.NonTerminal | ||
file | string | The preprocessed source file. |
Résultat | SlimDX.Generator.NonTerminal |
static JObject RunParser(Configuration configuration) { // run boost::wave on the primary source file to get a preprocessed file and a list of macros var preprocessor = new Preprocessor(configuration); Console.WriteLine(preprocessor.Run()); // before parsing, run some transformations on the preprocessed file to cut down on the size needed to be examined // this includes dropping any source that is not from the given primary or ancillary // sources, which is indicated in the preprocessed file by #line directives var source = preprocessor.Source; var rawSources = configuration.AdditionalHeaders.Concat(new[] { Path.Combine(Directory.GetCurrentDirectory(), source) }); var relevantSources = new List <string>(); foreach (string s in rawSources) { relevantSources.Add(Environment.ExpandEnvironmentVariables(s)); } source = Path.ChangeExtension(source, ".i"); Preprocessor.PostTransform(source, new HashSet <string>(relevantSources)); // run the parser on the preprocessed file to generate a model of the file in memory var grammarFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "header_grammar.cgt"); var parser = new HeaderParser(grammarFile); var root = parser.Parse(source).ToXml(); var json = ModelXml.Transform(root); // add a dependency to the base SlimDX.json file json.Add(new JProperty("dependencies", new JArray(new JValue("../SlimDX/SlimDX.json")))); return(json); }
static JObject RunParser(Configuration configuration) { // run boost::wave on the primary source file to get a preprocessed file and a list of macros var preprocessor = new Preprocessor(configuration); Console.WriteLine(preprocessor.Run()); // before parsing, run some transformations on the preprocessed file to cut down on the size needed to be examined // this includes dropping any source that is not from the given primary or ancillary // sources, which is indicated in the preprocessed file by #line directives var source = preprocessor.Source; var rawSources = configuration.AdditionalHeaders.Concat(new[] { Path.Combine(Directory.GetCurrentDirectory(), source) }); var relevantSources = new List<string>(); foreach (string s in rawSources) relevantSources.Add(Environment.ExpandEnvironmentVariables(s)); source = Path.ChangeExtension(source, ".i"); Preprocessor.PostTransform(source, new HashSet<string>(relevantSources)); // run the parser on the preprocessed file to generate a model of the file in memory var grammarFile = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "header_grammar.cgt"); var parser = new HeaderParser(grammarFile); var root = parser.Parse(source).ToXml(); var json = ModelXml.Transform(root); // add a dependency to the base SlimDX.json file json.Add(new JProperty("dependencies", new JArray(new JValue("../SlimDX/SlimDX.json")))); return json; }