예제 #1
0
        public void TestGenerateGrammar()
        {
            ProjectSerializationManager projectSerializationManager = new ProjectSerializationManager();
            Project sampleProject = projectSerializationManager.LoadProject(@"..\..\..\Projects\Figure8.eXo");

            PSMSchema        psmSchema        = sampleProject.SingleVersion.PSMSchemas[0];
            GrammarGenerator grammarGenerator = new GrammarGenerator();

            Exolutio.Model.PSM.Grammar.Grammar g = grammarGenerator.GenerateGrammar(psmSchema);

            System.Diagnostics.Debug.WriteLine("Not normalized grammar: ");
            foreach (ProductionRule productionRule in g.ProductionRules)
            {
                System.Diagnostics.Debug.WriteLine(productionRule.ToString());
            }

            System.Diagnostics.Debug.WriteLine(string.Empty);

            Normalizer normalizer = new Normalizer();

            normalizer.Controller = new Controller.Controller(sampleProject);
            normalizer.NormalizeSchema(psmSchema);

            g = grammarGenerator.GenerateGrammar(psmSchema);
            System.Diagnostics.Debug.WriteLine("Normalized grammar: ");
            foreach (ProductionRule productionRule in g.ProductionRules)
            {
                System.Diagnostics.Debug.WriteLine(productionRule.ToString());
            }

            System.Diagnostics.Debug.WriteLine(string.Empty);
        }
예제 #2
0
        public override void Execute(object parameter = null)
        {
            if (Current.ActiveDiagram != null && Current.ActiveDiagram is PSMDiagram)
            {
                GrammarGenerator generator = new GrammarGenerator();
                Exolutio.Model.PSM.Grammar.Grammar grammar = generator.GenerateGrammar((PSMSchema)Current.ActiveDiagram.Schema);

                GrammarWindow w = new GrammarWindow();
                w.DisplayedGrammar = grammar;
                w.ShowDialog();
            }
        }