コード例 #1
0
ファイル: State.cs プロジェクト: nikita-vanyasin/compiler
 public State(ParsHead head)
 {
     count=0;
     parsHead=head;
     first=new StateNode(0);
     first.laws.add(0,0);
     this.stateTravers(first);
 }
コード例 #2
0
 public nonTerminals(ParsHead PH)
 {
     this.parent = PH;
     first=null;
 }
コード例 #3
0
ファイル: mainForm.cs プロジェクト: nikita-vanyasin/compiler
 private void MakeParseTable_Click(object sender, System.EventArgs e)
 {
     try
     {
         this.parsHead = new ParsHead();
         foreach(string s in content.Lines)
             this.parsHead.load(s);
     }
     catch(Exception ee)
     {
         MessageBox.Show(ee.Message);
     }
 }
コード例 #4
0
ファイル: mainForm.cs プロジェクト: nikita-vanyasin/compiler
 private void tabControl1_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     try
     {
         if(tabControl1.SelectedIndex==1)//first follow
         {
             this.parsHead = new ParsHead();
             foreach(string s in content.Lines)
                 this.parsHead.load(s);
             this.comboxNonTerm.Items.Clear();
             nonTerminalNode temp=this.parsHead.Head.NonTerminalHead;
             if(temp==null)
                 return;
             else
                 temp=temp.next;
             while(temp!=null)
             {
                 this.comboxNonTerm.Items.Add(temp.item.Name);
                 temp=temp.next;
             }
             if(this.comboxNonTerm.Items.Count!=0)
                 this.comboxNonTerm.SelectedIndex=0;
         }
         else
         {
             if(tabControl1.SelectedIndex==2)
             {
                 result.Items.Clear();
                 if(this.parsTable!=null)
                 {
                     this.parsTable.showContents(this.result);
                     PrintProductions();
                     this.terminalCnt.Text="Count Terminals: "+this.parsHead.TerminalCount.ToString();
                     this.nonTerminalCnt.Text="Count of NonTerminals: "+this.parsHead.Head.NonTerminalCount;
                     this.lawCnt.Text="Count of Laws: "+parsHead.LawCount.ToString();
                     this.stateCnt.Text="Count of States:"+states.StateCount.ToString();
                 }
             }
         }
     }
     catch(Exception ee)
     {
         MessageBox.Show(ee.Message);
     }
 }
コード例 #5
0
ファイル: mainForm.cs プロジェクト: nikita-vanyasin/compiler
 private void New_Click(object sender, System.EventArgs e)
 {
     if(saveConfirm(sender,e))
     {
         this.content.Clear();
         this.Text="New Grammer";
         this.path="";
         this.parsTable = null;
         this.parsHead = null;
         this.result.Items.Clear();
         this.lstFirstFollow.Items.Clear();
     }
 }
コード例 #6
0
ファイル: mainForm.cs プロジェクト: nikita-vanyasin/compiler
        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!!!");
            }
        }