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)
        {
            Nfa nfa1 = r.MkNfa(names);
            int s0s  = names.next();
            Nfa nfa0 = new Nfa(s0s, s0s);

            foreach (KeyValuePair <int, ArrayList <Transition> > 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)
        {
            Nfa nfa1 = r1.MkNfa(names);
            Nfa nfa2 = r2.MkNfa(names);
            Nfa nfa0 = new Nfa(nfa1.Start, nfa2.Exit);

            foreach (KeyValuePair <int, ArrayList <Transition> > entry in nfa1.Trans)
            {
                nfa0.AddTrans(entry);
            }
            foreach (KeyValuePair <int, ArrayList <Transition> > entry in nfa2.Trans)
            {
                nfa0.AddTrans(entry);
            }
            nfa0.AddTrans(nfa1.Exit, null, nfa2.Start);
            return(nfa0);
        }
Esempio n. 3
0
        // If   nfa1 has form s1s ----> s1e
        // and  nfa2 has form s2s ----> s2e
        // then nfa0 has form s0s -eps-> s1s ----> s1e -eps-> s0e
        //                    s0s -eps-> s2s ----> s2e -eps-> s0e

        public override Nfa MakeNfa(Nfa.NameSource names)
        {
            var s0s = names.next();
            var s0e = names.next();

            var nfa0 = new Nfa(s0s, s0e);

            foreach (var regularExpression in _regularExpressions)
            {
                var nfa1 = regularExpression.MakeNfa(names);

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

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

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