Esempio n. 1
0
        // If   nfa1 has form s1s ----> s1e
        // then nfa0 has form s0s ----> s0s
        //                    s0s -eps-> s1s
        //                    s1e -eps-> s0s
        public override Nfa MkNfa(Nfa.NameSource names)
        {
            var nfa1 = _r.MkNfa(names);
            var s0s  = names.Next();
            var nfa0 = new Nfa(s0s, s0s);

            foreach (var entry in nfa1.Trans)
            {
                nfa0.AddTrans(entry);
            }

            nfa0.AddTrans(s0s, null, nfa1.Start);
            nfa0.AddTrans(nfa1.Exit, null, s0s);

            return(nfa0);
        }
Esempio n. 2
0
        // If   nfa1 has form s1s ----> s1e
        // and  nfa2 has form s2s ----> s2e
        // then nfa0 has form s1s ----> s1e -eps-> s2s ----> s2e
        public override Nfa MkNfa(Nfa.NameSource names)
        {
            var nfa1 = _r1.MkNfa(names);
            var nfa2 = _r2.MkNfa(names);
            var nfa0 = new Nfa(nfa1.Start, nfa2.Exit);

            foreach (var entry in nfa1.Trans)
            {
                nfa0.AddTrans(entry);
            }

            foreach (var entry in nfa2.Trans)
            {
                nfa0.AddTrans(entry);
            }

            nfa0.AddTrans(nfa1.Exit, null, nfa2.Start);

            return(nfa0);
        }
Esempio n. 3
0
 public abstract Nfa MkNfa(Nfa.NameSource names);