public void Case3() { Context test1 = new Context ("q", "a"); Context test2 = new Context ("", ""); Assert.IsNotNull (test1, "C03-A"); Assert.IsNotNull (test2, "C03-B"); }
public override Hashtable GetDelta() { ArrayList [] trans = GetDeltaAux (); Hashtable hash = new Hashtable (); foreach (ArrayList list in trans) { Context con = new Context ((string) list[0], (string) list [1]); string [] tstates = new string [list.Count - 2]; list.CopyTo (2, tstates, 0, tstates.Length); StringBuilder fstates = new StringBuilder (); int count = 1; foreach (string state in tstates) if (count++ != tstates.Length) fstates.AppendFormat ("{0}:", state); else fstates.AppendFormat ("{0}", state); hash.Add (con, fstates.ToString ()); } return hash; }
public void Case4() { int code1, code2; Context test1 = new Context ("q", "a"); Context test2 = new Context ("q", "a"); code1 = test1.GetHashCode (); code2 = test2.GetHashCode (); Console.WriteLine ("test1 object has HashCode: {0}", code1); Console.WriteLine ("test2 object has HashCode: {0}", code2); Assert.AreEqual (code1, code2, "C04"); }
public void Case2() { Context test1 = new Context ("q", "b"); Context test2 = new Context ("q", "b"); Assert.IsTrue (test1 == test2, "C02"); }
public void Case1() { Context test1 = new Context ("q", "a"); Context test2 = new Context ("q", "a"); Assert.AreEqual (test1, test2, "C01"); }
public bool DoTransition(char cInput) { Context con = new Context (current_state, cInput.ToString ()); current_state = (string) delta[con]; return (current_state != null); }
private void GetDeltaFinal(RegGram gram) { Hashtable hash = new Hashtable (); bool acepta = false; string [][] propositions = gram.Propositions; foreach (string [] prop in propositions) { string left = prop [0]; string right = prop [1]; if (right == "epsilon") acepta = true; if (right.IndexOf (":") == -1) { Context con = new Context (left, right); if (hash [con] == null) { hash.Add (con, "ZFinal"); } else { string temp = (string) hash [con]; hash.Remove (con); hash.Add (con, temp + ":ZFinal"); } } else { string [] sub = right.Split (':'); string subleft = sub [0]; string subright = sub [1]; Context con = new Context (left, subleft); if (hash [con] == null) { hash.Add (con, subright); } else { string temp = (string) hash [con]; hash.Remove (con); hash.Add (con, temp + ":" + subright); } } } foreach (string sym in alph) { hash.Add (new Context ("ZFinal", sym), "ERROR"); hash.Add (new Context ("ERROR", sym), "ERROR"); } delta = hash; string [] nfstates; if (acepta) { nfstates = new string [2]; nfstates [0] = "ZFinal"; nfstates [1] = gram.ISym; } else { nfstates = new string [1]; nfstates [0] = "ZFinal"; } f_states = nfstates; }