📄 复件 compile.java.bak
字号:
for (i=0;i<exn;i++)
{ for (j=1;j<=head[i][0];j++)
System.out.print(head[i][j]);
System.out.println();}
System.out.println("hellohello");
for (i=0;i<ucn;i++)
{ for (j=1;j<=follow[i][0];j++)
System.out.print(follow[i][j]);
System.out.println();}
buildtable();
//System.out.println(star);
//System.out.println("hello1");
drawtable();
for (i=0;i<ecn;i++)
elist.add(" "+ec[i]);
for (i=0;i<ucn;i++)
ulist.add(" "+uc[i]);
addin.setEnabled(false);
start.setEnabled(true);
return false;
}
void onresetclick()
{
addin.setEnabled(true);
start.setEnabled(false);
next.setEnabled(false);
star=0;
drawstep.removeAll();
drawstack.removeAll();
ulist.removeAll();
elist.removeAll();
input.setText("");
offg.setColor(Color.lightGray);
offg.fillRect(0,0,1999,799);
offg.drawString("asfaf",20,20);
g.drawImage(offscreen,0,0,drawarea);
show_desc();
}
boolean onnextclick()
{
if (!((star==3)||(star==4)))
{
showerror();
star=5;
return true;
}
star=4;
if (stack[stack[0]]>=0)
{
ch=uc[stack[stack[0]]];
}
else
{
ch=ec[-1-stack[stack[0]]];
}
//System.out.println(ch);
//System.out.println(s1.charAt(n));
if ((ch==s1.charAt(n))&&(ch=='$'))
{
drawstep.add("分析结束");
showstack();
star=5;
next.setEnabled(false);
}
else
if (ch==s1.charAt(n))
{
n++;
stack[0]--;
showstack();
drawstep.add("读入"+ch);
}
else
{
i=atwhere(s1.charAt(n),ec,ecn);
//System.out.println(s1.charAt(n));
//System.out.println(atwhere(s1.charAt(n),ec,ecn));
if (i==-1)
{
showerror();
return true;
}
// if (i==ecn)
// System.out.println("end");
j=stack[stack[0]];
stack[0]--;
if (j<0)
{
showerror();
return true;
}
//System.out.println(j);
//System.out.println(i);
//System.out.println(table[j][i]);
i=table[j][i];
if (i<0)
{
showerror();
return true;
}
// System.out.println(express[i][0]);
//System.out.println(express[i][1]);
for (j=express[i][0];j>1;j--)
{
if ((express[i][j]>=0)||(ec[-1-express[i][j]]!='e'))
{ stack[0]++;
stack[stack[0]]=express[i][j];
}
}
//System.out.println(stack[0]);
showstack();
s3=""+uc[express[i][1]]+"->";
for (j=2;j<=express[i][0];j++)
{
if (express[i][j]>=0)
s3=s3+uc[express[i][j]];
else
s3=s3+ec[-1-express[i][j]];
}
drawstep.add("使用"+s3);
}
s3="";
for (i=n;i<s1.length();i++)
s3+=s1.charAt(i);
input.setText(s3);
return false;
}
void showstack() {
int k;
s3="";
for (k=1;k<=stack[0];k++)
if (stack[k]>=0)
s3+=uc[stack[k]];
else
s3+=ec[-1-stack[k]];
drawstack.add(s3);
}
void showerror() {
drawstep.add("输入错误");
start.setEnabled(false);
next.setEnabled(false);
addin.setEnabled(false);
}
void drawtable() {
int k,m;
String s;
g=drawarea.getGraphics();
offg.setFont(f);
offg.setColor(Color.blue);
y=50;
if (inside('e',ec,ecn))
m=40+ecn*120;
else
m=160+ecn*120;
for (i=0;i<ucn;i++)
{
offg.drawLine(10,y-20,m,y-20);
offg.drawString(""+uc[i],20,y);
y+=30;
}
x=80;
m=30+ucn*30;
for (i=0;i<=ecn;i++)
if (ec[i]!='e')
{
offg.drawLine(x-30,10,x-30,m);
offg.drawString(""+ec[i],x,20);
x+=120;
}
y=50;
for (i=0;i<ucn;i++)
{
//System.out.println("hello");
x=60;
for (j=0;j<=ecn;j++)
{
//System.out.println("shit");
if (ec[j]!='e')
{
s=""+uc[i]+'-'+'>';
m=table[i][j];
if (m>=0)
{
for (k=2;k<=express[m][0];k++)
if (express[m][k]>=0)
s=s+uc[express[m][k]];
else
s=s+ec[-1-express[m][k]];
offg.drawString(s,x,y);
}
else
if (m==-5000)
offg.drawString("冲突",x,y);
x+=120;
}
}
y+=30;
}
offg.drawString("sdfas",10,100);//
g.drawImage(offscreen,0,0,drawarea);
}
boolean inside(char ch,char[] sh,int n) {
int i;
for (i=0;i<n;i++)
if (ch==sh[i])
return(true);
return(false);
}
int atwhere(char ch,char[] sh,int n) {
int i;
if (ch=='$')
return(ecn);
else
{
for (i=0;i<n;i++)
if (ch==sh[i])
return(i);
}
return(-1);
}
boolean inside2(int m,int[] a,int n) {
int i;
for (i=1;i<=n;i++)
if (m==a[i])
return(true);
return(false);
}
void empty() {
boolean[] label=new boolean[20];
int circle=0;
for (i=0;i<20;i++)
{
label[i]=false;
hollow[i]=false;
}
for (i=0;i<exn;i++)
if ((express[i][0]==2)&&(express[i][2]<0)&&(ec[-1-express[i][2]]=='e'))
{
hollow[express[i][1]]=true;
label[express[i][1]]=true;
}
for (i=0;i<exn;i++)
if (!(label[express[i][1]]))
for (j=2;j<express[i][0]+1;j++)
if (express[i][j]<0)
{
label[express[i][1]]=true;
hollow[express[i][1]]=false;
}
boolean bool;
while (true) {
circle++;
if (circle>1000)
{
showerror();
break;
}
for (i=0;i<exn;i++)
if (!(label[express[i][1]]))
{
bool=true;
for(j=2;j<express[i][0]+1;j++)
if (label[express[i][j]])
bool=bool&&hollow[express[i][j]];
else
j=20;
if ((j<20)&&(bool))
{
hollow[express[i][1]]=true;
label[express[i][1]]=true;
}
if ((j<20)&&(!bool))
{
hollow[express[i][1]]=false;
label[express[i][1]]=true;
}
}
bool=true;
for (i=0;i<ucn;i++)
{
bool=bool&&label[i];
System.out.println(label[i]);
}
System.out.println("");
if (bool)
break;
}
}
void first1() {
int k;
int circle=0;
for (i=0;i<20;i++)
first[i][0]=0;
for (i=0;i<exn;i++)
if ((express[i][2]<0)&&(!inside2(express[i][2],first[express[i][1]],first[express[i][1]][0])))
{
j=express[i][1];
first[j][0]++;
first[j][first[j][0]]=express[i][2];
//System.out.println(j);
//System.out.println(express[i][2]);
}
boolean bool;
do
{
circle++;
if (circle>2000)
{
showerror();
break;
}
bool=false;
for (i=0;i<exn;i++)
for (j=2;j<=express[i][0];j++)
{
if (express[i][j]>=0)
{
bool=addin(express[i][1],express[i][j]);
if (!(hollow[express[i][j]]))
j=20;
}
else
{
k=express[i][1];
if (!(inside2(express[i][j],first[k],first[k][0])))
{
bool=true;
first[k][0]+=1;
first[k][first[k][0]]=express[i][j];
}
j=20;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -