欢迎来到天天文库
浏览记录
ID:38518396
大小:132.50 KB
页数:11页
时间:2019-06-14
《从正规文法构造有穷状态自动机》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、课程名称:从正规文法构造有穷状态自动机年级/专业/班:11级计算机类(二)班姓名:徐勇兵学号:E01114278从正规文法构造有穷状态自动机输入:任意的正规文法输出:相应的有穷状态自动机要求:识别有穷状态自动机是确定的还是非确定的,生成相应的五元组形式。说明:应检查输入的是否正规文法。实验截图:测试一:测试二:***************************************************************************测试三:importjava.util.Vector;impo
2、rtjavax.swing.JOptionPane;classTools{publicVectorprotection(Vectorvs){Vectornewvector=newVector();for(inti=0;i>doubleprotection(Vector3、ng>>vs){Vector>newvector=newVector>();for(inti=0;iproduce=(Vector)vs.get(i);Vectortemp=newVector();for(intj=0;j4、tor.add(temp);}//forireturnnewvector;}publicVectoraddElements(Vectorvs,Vectortemp){for(inti=0;iaddElements(Vectorvs,Vector<5、String>temp){}//classtoolsclassElements{Vectorend=newVector();//表示终结符Vectornoend=newVector();//表示非终结符Vector>produce=newVector>();//产生式publicvoidsetend(){//终结符元素添加while(true){Strings=JOptionPane.showIn6、putDialog(null,"请输入终结符");if(s==null){return;}//ifend.add(s);}//while}//publicvoidaddend(){//元素添加publicvoidsetnoend(){//非终结符元素添加while(true){Strings=JOptionPane.showInputDialog(null,"非请输入终结符");if(s==null){return;}//ifnoend.add(s);}//while}//publicvoidaddnoend(){//7、publicvoidsetproduce(){while(true){Strings=JOptionPane.showInputDialog(null,"请输入产生式,->隔开");if(s==null)return;Vectortemp=newVector();temp.add(s.split("->")[0]);temp.add(s.split("->")[1]);produce.add(temp);}//while}//publicvoidaddproduce()publicVec8、torgetend(){returnend;}publicVectorgetnoend(){returnnoend;}publicVector>getproduce(){returnthis.produce;}publicvoidrun(){/*************
3、ng>>vs){Vector>newvector=newVector>();for(inti=0;iproduce=(Vector)vs.get(i);Vectortemp=newVector();for(intj=0;j4、tor.add(temp);}//forireturnnewvector;}publicVectoraddElements(Vectorvs,Vectortemp){for(inti=0;iaddElements(Vectorvs,Vector<5、String>temp){}//classtoolsclassElements{Vectorend=newVector();//表示终结符Vectornoend=newVector();//表示非终结符Vector>produce=newVector>();//产生式publicvoidsetend(){//终结符元素添加while(true){Strings=JOptionPane.showIn6、putDialog(null,"请输入终结符");if(s==null){return;}//ifend.add(s);}//while}//publicvoidaddend(){//元素添加publicvoidsetnoend(){//非终结符元素添加while(true){Strings=JOptionPane.showInputDialog(null,"非请输入终结符");if(s==null){return;}//ifnoend.add(s);}//while}//publicvoidaddnoend(){//7、publicvoidsetproduce(){while(true){Strings=JOptionPane.showInputDialog(null,"请输入产生式,->隔开");if(s==null)return;Vectortemp=newVector();temp.add(s.split("->")[0]);temp.add(s.split("->")[1]);produce.add(temp);}//while}//publicvoidaddproduce()publicVec8、torgetend(){returnend;}publicVectorgetnoend(){returnnoend;}publicVector>getproduce(){returnthis.produce;}publicvoidrun(){/*************
4、tor.add(temp);}//forireturnnewvector;}publicVectoraddElements(Vectorvs,Vectortemp){for(inti=0;iaddElements(Vectorvs,Vector<
5、String>temp){}//classtoolsclassElements{Vectorend=newVector();//表示终结符Vectornoend=newVector();//表示非终结符Vector>produce=newVector>();//产生式publicvoidsetend(){//终结符元素添加while(true){Strings=JOptionPane.showIn
6、putDialog(null,"请输入终结符");if(s==null){return;}//ifend.add(s);}//while}//publicvoidaddend(){//元素添加publicvoidsetnoend(){//非终结符元素添加while(true){Strings=JOptionPane.showInputDialog(null,"非请输入终结符");if(s==null){return;}//ifnoend.add(s);}//while}//publicvoidaddnoend(){//
7、publicvoidsetproduce(){while(true){Strings=JOptionPane.showInputDialog(null,"请输入产生式,->隔开");if(s==null)return;Vectortemp=newVector();temp.add(s.split("->")[0]);temp.add(s.split("->")[1]);produce.add(temp);}//while}//publicvoidaddproduce()publicVec
8、torgetend(){returnend;}publicVectorgetnoend(){returnnoend;}publicVector>getproduce(){returnthis.produce;}publicvoidrun(){/*************
此文档下载收益归作者所有