预测分析报告.docx
预测分析报告预测分析法实验报告下面是你输入的文法G:非终结符号集合为:A,B,C,D,Z终结符符号集合为:a,b,c,dGZ:A->cDB->bCC->C->BcAD->aBDD->dZ->aAcBZ->Bd可以推出空串的非终结符集合为:C非终结符号的FIRST集合:FIRST(A)=cFIRST(B)=bFIRST(C)=,bFIRST(D)=a,dFIRST(Z)=a,b非终结符号的FOLLOW集合:FOLLOW(A)=c,a,d,#FOLLOW(B)=c,a,d,#FOLLOW(C)=c,a,d,#FOLLOW(D)=c,a,d,#FOLLOW(Z)=#各产生式的SELECT集合:SELECT(A->cD)=cSELECT(B->bC)=bSELECT(C->)=,c,a,d,#SELECT(C->BcA)=bSELECT(D->aBD)=aSELECT(D->d)=dSELECT(Z->aAcB)=aSELECT(Z->Bd)=b输入的文法是一个LL(1)文法。下面是生成的预测分析表:abcd#AcDBbCCBcADaBDdZaAcBBd例如:对符号串acabdcb#的分析过程:步骤分析栈剩余输入串所用产生式12345678910111213141516#Z#BcAa#BcA#BcDc#BcD#BcDBa#BcDB#BcDCb#BcDC#BcD#Bcd#Bc#B#Cb#C#acabdcb#acabdcb#cabdcb#cabdcb#abdcb#abdcb#bdcb#bdcb#dcb#dcb#dcb#cb#b#b#Z->aAcBa匹配A->cDc匹配D->aBDa匹配B->bCb匹配C->D->dd匹配c匹配B->bCb匹配C->接受