Ejemplo n.º 1
0
 //public FiniteAutomaton(System.IO.FileInfo source)
 //{
 //    loadAutomaton(source);
 //}
 //public FiniteAutomaton(System.String filename)
 //{
 //    if (!loadAutomaton(filename))
 //        throw new InvalidAutomatonFormat("The source file \"" + filename + "\" does not define a valid automaton.");
 //}
 public virtual FAState createState()
 {
     FAState st = new FAState(num);
     num++;
     states.Add(st);
     return st;
 }
Ejemplo n.º 2
0
 public void addPre(string a, FAState n)
 {
     if (!pre.ContainsKey(a))
     {
         //UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
         pre.Add(a, new HashSet<FAState>() { n });
     }
     else
     {
         pre[a].Add(n);
     }
 }
Ejemplo n.º 3
0
 ////UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
 //public Set < FAState > getNext(String a)
 ////UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
 //public Set < FAState > getPre(String a)
 public virtual void addNext(System.String a, FAState b, FiniteAutomaton auto)
 {
     if (!next.ContainsKey(a))
     {
         //UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
         HashSet<FAState> S = new HashSet<FAState>();
         S.Add(b);
         next.Add(a, S);
     }
     else
         next[a].Add(b);
 }
Ejemplo n.º 4
0
        ////UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
        //public Set < FAState > getNext(String a)
        ////UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
        //public Set < FAState > getPre(String a)

        public virtual void addNext(System.String a, FAState b, FiniteAutomaton auto)
        {
            if (!next.ContainsKey(a))
            {
                //UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
                HashSet <FAState> S = new HashSet <FAState>();
                S.Add(b);
                next.Add(a, S);
            }
            else
            {
                next[a].Add(b);
            }
        }
Ejemplo n.º 5
0
 public void addPre(string a, FAState n)
 {
     if (!pre.ContainsKey(a))
     {
         //UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
         pre.Add(a, new HashSet <FAState>()
         {
             n
         });
     }
     else
     {
         pre[a].Add(n);
     }
 }
Ejemplo n.º 6
0
 public virtual FAState createState(System.String name)
 {
     int i = S.IndexOf(name);
     if (i < 0)
     {
         FAState st = new FAState(num);
         S.Add(name);
         states.Add(st);
         num++;
         return st;
     }
     else
     {
         return states[i];
     }
 }
Ejemplo n.º 7
0
        public virtual void addTransition(FAState state, FAState state2, System.String label)
        {
            if (state.next.ContainsKey(label))
            {
                if (state.next[label].Contains(state2))
                {
                    return;
                }
            }

            trans++;
            if (!alphabet.Contains(label))
            {
                alphabet.Add(label);
            }
            state.addNext(label, state2, this);
            state2.addPre(label, state);
        }
Ejemplo n.º 8
0
        /// <param name="s">sate
        /// </param>
        /// <returns> if the set of out-going transitions of this state covers that of s 
        /// </returns>
        public virtual bool covers(FAState s)
        {
            foreach (string key in s.next.Keys)
            {
                if (!next.ContainsKey(key))
                {
                    return false;
                }
            }

            return true;

            ////UPGRADE_NOTE: There is an untranslated Statement.  Please refer to original code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1153'"
            //while (it.hasNext())
            //{
            //    System.String ss = it.next();
            //    if (!next.containsKey(ss))
            //        return false;
            //}
            //return true;
        }
Ejemplo n.º 9
0
        /// <param name="s">sate
        /// </param>
        /// <returns> if the set of out-going transitions of this state covers that of s
        /// </returns>
        public virtual bool covers(FAState s)
        {
            foreach (string key in s.next.Keys)
            {
                if (!next.ContainsKey(key))
                {
                    return(false);
                }
            }

            return(true);

            ////UPGRADE_NOTE: There is an untranslated Statement.  Please refer to original code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1153'"
            //while (it.hasNext())
            //{
            //    System.String ss = it.next();
            //    if (!next.containsKey(ss))
            //        return false;
            //}
            //return true;
        }
Ejemplo n.º 10
0
 public virtual System.String getName(FAState s)
 {
     string name = S[s.ID];
     return name == "" ? s.ToString() : name;
 }
Ejemplo n.º 11
0
        internal virtual void tarjan(FAState v)
        {
            v_index.Add(v.id, index);
            v_lowlink.Add(v.id, index);
            index++;
            S.Push(v);

            foreach (KeyValuePair<string, HashSet<FAState>> pair in v.next)
            {
                //System.String next = pair.Key;
                foreach (FAState v_prime in pair.Value)
                {
                    if (!v_index.ContainsKey(v_prime.id))
                    {
                        tarjan(v_prime);
                        v_lowlink.Add(v.id, Math.Min(v_lowlink[v.id], v_lowlink[v_prime.id]));
                    }
                    else if (S.Contains(v_prime))
                    {
                        v_lowlink.Add(v.id, Math.Min(v_lowlink[v.id], v_index[v_prime.id]));
                    }
                }
            }

            if (v_lowlink[v.id] == v_index[v.id])
            {
                HashSet<FAState> SCC = new HashSet<FAState>();
                while (S.Count > 0)
                {
                    FAState t = S.Pop();
                    SCC.Add(t);

                    if (t.id == v.id)
                    {
                        break;
                    }
                }

                foreach (FAState st in SCC)
                {
                    if (st.next.ContainsKey("1"))
                    {
                        HashSet<FAState> states = st.next["1"];

                        //states..retainAll(SCC);
                        if (states.Overlaps(SCC))
                        {
                            foreach (FAState state in SCC)
                            {
                                OneSCC.Add(state);
                            }

                            ////is 1-SCC
                            ////UPGRADE_NOTE: There is an untranslated Statement.  Please refer to original code. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1153'"
                            //while (SCC_it2.hasNext())
                            //{
                            //    OneSCC.add(SCC_it2.next());
                            //}
                            break;
                        }
                    }

                }
            }
        }
Ejemplo n.º 12
0
        public int CompareTo(System.Object obj)
        {
            FAState o = obj as FAState;

            return(o.ID - id);
        }