Пример #1
0
 protected virtual void MakeParser()
 {
     Parser = new SparkParser();
 }
Пример #2
0
        public override void RunFromArgs(string[] args)
        {
            string generatorName = null;
            string outName = null;
            OptionSet optionSet = new OptionSet()
            {
                {"g|generator=", x => generatorName = x},
                {"o|out=", x => outName = x}
            };

            List<string> codeDirs = optionSet.Parse(args);

            if (String.IsNullOrWhiteSpace(generatorName))
            {
                generatorName = "Static";
            }

            if (codeDirs.Count == 0)
            {
                codeDirs.Add("%game%");
            }

            IOutputGenerator generator = CreateGenerator(generatorName);
            generator.Out = outName;

            SparkParser parser = new SparkParser();
            Game game = new Game();

            foreach (string unformattedCodeDir in codeDirs)
            {
                string codeDir = FormatFolderPath(unformattedCodeDir);

                string[] ignoreList;
                try
                {
                    ignoreList = File.ReadAllLines(Utils.PathInExecutingDir("ns2docs-ignore.txt"));
                }
                catch (FileNotFoundException)
                {
                    ignoreList = new string[0];
                }

                IEnumerable<string> files = FindFiles(codeDir, ignoreList);
                foreach (string file in files)
                {
                    string contents = ReadAllText(file);
                    contents = contents.Replace("Copyright \uFFFD", "Copyright ©");

                    SourceCode sourceCode = new SourceCode(file, codeDir, contents);
                    sourceCode.LastWriteTime = new FileInfo(file).LastWriteTime;
                    sourceCode.PredictLibrary();

                    try
                    {
                        parser.ParseSourceCode(game, sourceCode);
                        Console.WriteLine(String.Format(Resources.ParsedLuaFile, sourceCode.RelativeName));
                    }
                    catch (ParseException e)
                    {
                        var msg = String.Format(Resources.ParseError, file, e.InnerException.Message);
                        Console.WriteLine(msg);

                        if (Debugger.IsAttached)
                        {
                            throw e;
                        }
                    }

                }
            }
            game.ReapPotentialStaticFields();

            GenerateDocumentation(generator, game);
        }