public void TestParsing1() { Automaton a = AutomatonParser.ParseAutomaton(@" E={a|O,b|O},true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); }
/// <summary> /// ButtonClickEvent to evaluate the set of sentences with the <see cref="Automaton"/> defined. /// </summary> /// <param name="sender">The sender for the event.</param> /// <param name="e">The <see cref="EventArgs"/> for the event.</param> private void BtnEval_Click(object sender, EventArgs e) { Automaton a = AutomatonParser.ParseAutomaton(this.rtbxAutomaton.Text); List <ParseStringResults> allResults = new List <ParseStringResults>(); foreach (string s in this.rtbxStringsToEval.Lines) { try { ParseStringResults currResults = AutomatonEvaluator.EvalAutomaton(a, s); allResults.Add(currResults); } catch (Exception) { // MATTHEWC: TODO: Maybe report errors separately? // Maybe dummy up a ParseStringResults with error data? } } CtlVParseStringResultsLVAndDetail disp = new CtlVParseStringResultsLVAndDetail(); disp.ParseStringResultsOnControls = allResults; MyGUIUtilities.DisplayUserControlInForm(disp, "Evaluated Strings via Automata", true); }
public void TestParsing2() { //this test set tests parsing with spaces at odd locations. // I'm alternating the location of spaces only on the e-line, in every categorical distinct location Automaton a = AutomatonParser.ParseAutomaton(@" E ={a|O,b|O},true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); a = AutomatonParser.ParseAutomaton(@" E= {a|O,b|O},true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); a = AutomatonParser.ParseAutomaton(@" E={ a|O,b|O},true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); a = AutomatonParser.ParseAutomaton(@" E={a |O,b|O},true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); a = AutomatonParser.ParseAutomaton(@" E={a| O,b|O},true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); a = AutomatonParser.ParseAutomaton(@" E={a|O ,b|O},true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); a = AutomatonParser.ParseAutomaton(@" E={a|O, b|O},true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); a = AutomatonParser.ParseAutomaton(@" E={a|O,b|O },true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); a = AutomatonParser.ParseAutomaton(@" E={a|O,b|O} ,true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); a = AutomatonParser.ParseAutomaton(@" E= {a|O,b|O}, true O={a|E,b|E},false".Trim()); Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); a = AutomatonParser.ParseAutomaton(@" E={a|O,b|O},true O={a|E,b|E},false".Trim()); // There is a space after the end of true on the first line. Assert.IsTrue(GenerateExpectedAutomaton1().ValueEquals(a)); }
/// <summary> /// ButtonClickEvent to parse the <see cref="Automaton"/>. /// </summary> /// <param name="sender">The sender for the event.</param> /// <param name="e">The <see cref="EventArgs"/> for the event.</param> private void BtnParse_Click(object sender, EventArgs e) { Automaton a = AutomatonParser.ParseAutomaton(this.rtbxAutomaton.Text); MessageBox.Show("Automaton parsed successfully."); }