LL1 first follow集

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

课程名称: LL1文法的判别

年级/专业/班: 11级计算机类(二)班

姓名: 徐勇兵

学号: E01114278

import java.util.Vector;

import javax.swing.JOptionPane;

class Tools{

public Vector protection(Vector vs){

Vector newvector=new Vector();

for(int i=0;i

newvector.add(vs.get(i));

return newvector;

}

public Vector> doubleprotection(Vector> vs){ Vector> newvector=new Vector>();

for(int i=0;i

Vector produce=(Vector)vs.get(i);

Vector temp=new V ector();

for(int j=0;j

temp.add((String)produce.get(j));

}//for j

newvector.add(temp);

}//for i

return newvector;

}

}

class Elements{

Vector end=new V ector();//表示终结符

Vector noend=new Vector();//表示非终结符

Vector> produce=new Vector>();//产生式

public void setend(){//终结符元素添加

while(true)

{

String s=JOptionPane.showInputDialog(null,"请输入终结符");

if(s==null)

{ return;

}//if

end.add(s);

}//while

}//public void addend(){//元素添加

public void setnoend(){//非终结符元素添加

while(true)

{

String s=JOptionPane.showInputDialog(null,"非请输入终结符");

if(s==null)

{ return;

}//if

noend.add(s);

}//while

}//public void addnoend(){//

public void setproduce(){

while(true)

{

String s=JOptionPane.showInputDialog(null,"请输入产生式,->隔开");

if(s==null)

return;

Vector temp=new Vector();

temp.add(s.split("->")[0]);

temp.add(s.split("->")[1]);

produce.add(temp);

}//while

}//public void addproduce()

public Vector getend(){

return end;

}

public Vector getnoend(){

return noend;

}

public Vector> getproduce(){

return this.produce;

}

public void run(){

/*************************TEST********************************/ end.add("a");

end.add("b");

end.add("c");

end.add("e");

noend.add("S");

noend.add("A");

noend.add("B");

noend.add("C");

noend.add("D");

Vector temp=new Vector();

temp.add("S");

temp.add("AB");

produce.add(temp);

/*************************/

Vector temp1=new Vector();

temp1.add("S");

temp1.add("bC");

produce.add(temp1);

/*************************/

Vector temp2=new Vector();

temp2.add("A");

temp2.add("e");

produce.add(temp2);

/*************************/

Vector temp3=new Vector();

temp3.add("A");

temp3.add("b");

produce.add(temp3);

/*************************/

Vector temp4=new Vector();

相关文档
最新文档