private void tsbVerifyMachine_Click(object sender, EventArgs e) { Regram <string, char> regram = getRegram(); if (regram == null) { return; } }
private void stbConsole_Click(object sender, EventArgs e) { Regram <string, char> regram = getRegram(); if (regram == null) { return; } FrmConsole c = new FrmConsole(regram.ToString()); c.MdiParent = this.MdiParent; c.Show(); }
private Regram <string, char> getRegram() { Regram <string, char> regram = new Regram <string, char>(this.alphabetSource.GetTableArray()); foreach (DataGridViewRow dataRow in this.dgvTransitions.Rows) { if (dataRow.Cells[2].Value == null || dataRow.Cells[2].Value.ToString() == "") { continue; } string from = dataRow.Cells[0].Value.ToString(); string to = dataRow.Cells[1].Value.ToString(); char symbol = dataRow.Cells[2].Value.ToString().First(); regram.AddTransition(from, to, symbol); } foreach (DataGridViewRow dataRow in this.dgvStates.Rows) { if (dataRow.Cells[0].Value == null || dataRow.Cells[0].Value.ToString() == "") { continue; } string name = dataRow.Cells[0].Value.ToString(); bool startState = (((dataRow.Cells[1]).Value == null) ? false : (bool)(dataRow.Cells[1]).Value); bool endState = (((dataRow.Cells[2]).Value == null) ? false : (bool)(dataRow.Cells[2]).Value); if (startState) { regram.StartState = name; } if (endState) { regram.EndStates.Add(name); } } if (!regram.IsMachineValid()) { MessageBox.Show("Machine is not valid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return(null); } tsbConsole.Enabled = true; tsbToDFA.Enabled = true; tsbToNDFA.Enabled = true; tsbVerifyLanguage.Enabled = true; return(regram); }
private void tsbToRegram_Click(object sender, EventArgs e) { DFA <string, char> dfa = getDFA(); if (dfa == null) { return; } Regram <string, char> regram = SearchAlgorithmParser.Converter <string, char> .ConvertToRegram(dfa); FrmRegularGrammar frmRegram = new FrmRegularGrammar(regram); frmRegram.MdiParent = this.MdiParent; frmRegram.Show(); }
private void tsbToNDFA_Click(object sender, EventArgs e) { Regram <string, char> regram = getRegram(); if (regram == null) { return; } NDFA <string, char> ndfa = SearchAlgorithmParser.Converter <string, char> .ConvertToNDFA(regram, 'e'); FrmNDFA frmNdfa = new FrmNDFA(ndfa); frmNdfa.MdiParent = this.MdiParent; frmNdfa.Show(); }
private void tsbToDFA_Click(object sender, EventArgs e) { Regram <string, char> regram = getRegram(); if (regram == null) { return; } DFA <MultiState <string>, char> dfa = SearchAlgorithmParser.Converter <string, char> .ConvertToDFA(regram, new SearchAlgorithmParser.MultiStateViewConcat <string>("", "O")); FrmDFA frmDfa = new FrmDFA(dfa); frmDfa.MdiParent = this.MdiParent; frmDfa.Show(); }
private void tsbToRegram_Click(object sender, EventArgs e) { NDFA <string, char> ndfa = getNDFA(); if (ndfa == null) { return; } Regram <MultiState <string>, char> regram = SearchAlgorithmParser.Converter <string, char> .ConvertToRegram(ndfa, new SearchAlgorithmParser.MultiStateViewConcat <string>("", "O")); FrmRegularGrammar frmRegram = new FrmRegularGrammar(regram); frmRegram.MdiParent = this.MdiParent; frmRegram.Show(); }
private void tsbVerifyLanguage_Click(object sender, EventArgs e) { Regram <string, char> regram = getRegram(); if (regram == null) { return; } string value = Prompt.ShowDialog("Fill in your text", "Validate language"); if (regram.Validate(value.ToArray())) { MessageBox.Show("This string is valid", "Success", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); } else { MessageBox.Show("This string is invalid", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }