Beispiel #1
0
        public void AjouterDfa(Auto UserAuto)
        {
            if (UserAuto.Automate == null) return;
            Selected = UserAuto;

            Automates_list.Add(UserAuto);

            // l'automate Dfa
            Dfa UserDfa_ = new Dfa();
            UserDfa_ = ((Dfa)UserAuto.Automate).toDfa();
            UserDfa_.Name = ((Dfa)UserAuto.Automate).Name + "[Dfa]";

            Auto UserAuto_Dfa_ = new Auto(UserDfa_);
            UserAuto_Dfa_.type = Automata.TYPE.Dfa;
            Automates_list.Add(UserAuto_Dfa_);

            // l'automate Nfa
            Nfa UserNfa_ = new Nfa();
            UserNfa_ = ((Dfa)UserAuto.Automate).toNfa();
            UserNfa_.Name = ((Dfa)UserAuto.Automate).Name + "[Nfa]";

            Auto UserAuto_Nfa_ = new Auto(UserNfa_);
            UserAuto_Nfa_.type = Automata.TYPE.Nfa;
            Automates_list.Add(UserAuto_Nfa_);

            // l'automate PGfa
            PGfa UserPGfa = new PGfa();
            UserPGfa = ((Dfa)UserAuto.Automate).toPGfa();
            UserPGfa.Name = ((Dfa)UserAuto.Automate).Name + "[PGfa]";

            Auto UserAuto_PGfa = new Auto(UserPGfa);
            UserAuto_PGfa.type = Automata.TYPE.PGfa;
            Automates_list.Add(UserAuto_PGfa);

            // l'automate Gfa
            Gfa UserGfa = new Gfa();
            UserGfa = ((Dfa)UserAuto.Automate).toGfa();
            UserGfa.Name = ((Dfa)UserAuto.Automate).Name + "[Gfa]";

            Auto UserAuto_Gfa = new Auto(UserGfa);
            UserAuto_Gfa.type = Automata.TYPE.Gfa;
            Automates_list.Add(UserAuto_Gfa);

            // l'automate reduit
            Dfa UserDfa_reduit = new Dfa();
            UserDfa_reduit = ((Dfa)UserAuto.Automate).toReduced();
            UserDfa_reduit.Name = ((Dfa)UserAuto.Automate).Name + "[Reduit]";

            Auto UserAuto_DfaReduit = new Auto(UserDfa_reduit);
            UserAuto_DfaReduit.type = Automata.TYPE.Dfa;
            Automates_list.Add(UserAuto_DfaReduit);

            // l'automate complet
            Dfa UserDfa_complet = new Dfa();
            UserDfa_complet = ((Dfa)UserAuto.Automate).toComplete();
            UserDfa_complet.Name = ((Dfa)UserAuto.Automate).Name + "[Complet]";

            Auto UserAuto_DfaComplet = new Auto(UserDfa_complet);
            UserAuto_DfaComplet.type = Automata.TYPE.Dfa;
            Automates_list.Add(UserAuto_DfaComplet);

            TreeNode node_automate = new TreeNode(UserAuto.ToString());
            TreeNode node_automate_Dfa = new TreeNode(UserAuto_Dfa_.ToString());
            TreeNode node_automate_Nfa = new TreeNode(UserAuto_Nfa_.ToString());
            TreeNode node_automate_PGfa = new TreeNode(UserAuto_PGfa.ToString());
            TreeNode node_automate_Gfa = new TreeNode(UserAuto_Gfa.ToString());
            TreeNode node_automate_DfaReduit = new TreeNode(UserAuto_DfaReduit.ToString());
            TreeNode node_automate_DfaComplet = new TreeNode(UserAuto_DfaComplet.ToString());

            node_automate.ContextMenuStrip = RightMenu;
            node_automate_Dfa.ContextMenuStrip = RightMenu;
            node_automate_Nfa.ContextMenuStrip = RightMenu;
            node_automate_PGfa.ContextMenuStrip = RightMenu;
            node_automate_Gfa.ContextMenuStrip = RightMenu;
            node_automate_DfaReduit.ContextMenuStrip = RightMenu;
            node_automate_DfaComplet.ContextMenuStrip = RightMenu;

            node_automate.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto.type);
            node_automate_Dfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_Dfa_.type);
            node_automate_Nfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_Nfa_.type);
            node_automate_PGfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_PGfa.type);
            node_automate_Gfa.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_Gfa.type);
            node_automate_DfaReduit.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_DfaReduit.type);
            node_automate_DfaComplet.ToolTipText = Enum.GetName(typeof(Automata.TYPE), UserAuto_DfaComplet.type);

            node_automate.Nodes.Add(node_automate_Dfa);
            node_automate.Nodes.Add(node_automate_Nfa);
            node_automate.Nodes.Add(node_automate_PGfa);
            node_automate.Nodes.Add(node_automate_Gfa);
            node_automate.Nodes.Add(node_automate_DfaReduit);
            node_automate.Nodes.Add(node_automate_DfaComplet);
            Automates_tree.Nodes.Add(node_automate);

            //node_automate.Nodes.Add(node_automate);
            node_automate.Expand();

            ((Dfa)UserAuto.Automate).Draw(Drawpanel, true);
            ((Dfa)UserAuto.Automate).Afficher_grid(transition_Grid);
            Type_label.Text = "L'automate : " + ((Automata)Selected.Automate).Name + "  de type : " + Selected.type.ToString();
            Drawpanel.Refresh();
        }
Beispiel #2
0
 /// <summary>
 /// Transformer la grammaire en un automate généralisé
 /// </summary>
 /// <returns></returns>
 public Gfa toGfa()
 {
     Gfa_CV = new Gfa();
     Gfa_CV.Name = this.Name + "_Gfa";
     Gfa_CV.X = new ArrayList(this.X);
     Gfa_CV.X.Insert(0, Automata.EPSILON);
     int Fi = this.V.Count;
     Gfa_CV.SetStateNumber(Fi + 1);
     Gfa_CV.AddFinalState(Fi);
     Gfa_CV.S0 = this.V.IndexOf(this.S);
     StCorTab = this.V;
     Gfa_CV.Read = new ArrayList(Gfa_CV.X);
     Gfa_CV.Read.AddRange(this.Read);
     Gfa_CV.InitI();
     foreach (char A in this.V)
         foreach (String production in this.getProductions(A))
         {
             Char B = getVar(production);
             string W = getWord(production);
             if (B != NOVARIABLE)
                 Gfa_CV.AddInstruction(V.IndexOf(A), W, V.IndexOf(B));
             else
                 Gfa_CV.AddInstruction(V.IndexOf(A), W, Fi);
         }
     return Gfa_CV;
 }
Beispiel #3
0
 public override Gfa toGfa()
 {
     Gfa temp = new Gfa(this.X , this.S , this.S0,this.F,(ArrayList[,])this.getInstructionTable());
     return temp;
 }