Esempio n. 1
0
        static void Main(string[] args)
        {
            var options    = new CommandLineArguments();
            var argsParser = new CommandLineAnalyzer <CommandLineArguments>();

            if (argsParser.TryParse(args, options) && !options.Help)
            {
                ParsingGrammar grammar;

                if (options.XmlGrammar)
                {
                    var loader = new GrammarXmlSerializer();
                    grammar = loader.LoadFromFile(options.GrammarFile);
                }
                else
                {
                    grammar = DefenitionsGrammar.TryParse(File.ReadAllText(options.GrammarFile));
                }

                if (!string.IsNullOrWhiteSpace(options.StartRule))
                {
                    grammar.StartRuleName = options.StartRule;
                }

                var sg = new GrammarModelSourceGenerator();

                if (!string.IsNullOrWhiteSpace(options.Namespace))
                {
                    sg.Namespace = options.Namespace;
                }

                sg.Public = options.Public;

                var generatedText = sg.Generate(grammar);

                File.WriteAllText(options.ModelFile, generatedText.GetContentAsString());
            }
            else
            {
                Console.WriteLine(argsParser.MakeHelp());
            }
        }
 public LtlAutomatonTextParser()
 {
     _grammar = DefenitionsGrammar.TryParse(LtlParserResources.SourceGrammarText);
 }