Exemple #1
0
        private void MakeStates_Click(object sender, System.EventArgs e)
        {
            try
            {
                result.Items.Clear();

                parsHead=new ParsHead();
                foreach(string s in content.Lines)
                    parsHead.load(s);
                states=new State(parsHead);
                states.create();
                parsTable=new ParsTable(states.StateCount,ParsHead.terminals,parsHead.Head,this.dgTabel);
                states.makeParsTable(this.parsTable);

                parsTable.showContents(result);

                PrintProductions();

                tabControl1.SelectedIndex=2;
                parsTable.writeGrid();
                SaveFileDialog saveDlg=new SaveFileDialog();
                saveDlg.Filter="(*.prt)|*.prt";
                if(saveDlg.ShowDialog()==DialogResult.OK)
                {

                    StreamWriter sw = new StreamWriter(saveDlg.FileName);
                    foreach (string s in result.Items)
                        sw.WriteLine(s);
                    sw.Close();

                //	parsTable.saveTo(sw);

                }
            }
            catch(Exception ex)
            {
            //				MessageBox.Show(ex.Message);
                MessageBox.Show("Grammar is incorrect : please check your grammar , example : There is one NonTerminal in Right side that never apear in left side!!!");
            }
        }