freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

編譯原理課程設(shè)計(jì)ll遞歸下降分析器(文件)

2024-10-29 06:36 上一頁面

下一頁面
 

【正文】 沒說明“, ”error 0012: 賦值語句中,賦值號(hào)左部標(biāo)識(shí)符屬性應(yīng)是變量“, ”error 0013: 賦值語句左部標(biāo)識(shí)符應(yīng)是賦值號(hào):=“, ”error 0014: call后應(yīng)為標(biāo)識(shí)符“, ”error 0015: call后標(biāo)識(shí)符屬性應(yīng)為過程“, ”error 0016: 條件語句中丟了then“, ”error 0017: 丟了end或。// 初始化存儲(chǔ)保留字strcpy(word[2],”call“)。strcpy(word[6],”end“)。strcpy(word[10],”read“)。strcpy(word[14],”var“)。wsym[2]= CALLSYM。wsym[6]= ENDSYM。wsym[10]= READSYM。wsym[14]= VARSYM。memset(ssym,0,100*sizeof(symbol))。+39。]= MINUS。ssym[39。(39。]= RPAREN。ssym[39。.39。]= NEQ。ssym[39。// 初始化類PCODE指令助記符表strcpy(mnemonic[OPR],” opr “)。strcpy(mnemonic[INT],” int “)。// 初始化聲明開始符號(hào)集合 (BEGINSYM),(CALLSYM),(IFSYM),(WHILESYM)。// 行緩沖區(qū)指針cx= 0。// last character read}kk= al。// 出錯(cuò)處理,打印出錯(cuò)位置和出錯(cuò)代碼 void PL0::error(int n){ char s[10]。//error count }//error end // 詞法分析,讀取一個(gè)單詞void PL0::getsym(){ if(sourceEnd)return。||ch==9)getch()。k= k+1。if(k = kk)kk = k。}while(kk k)。// 判斷是否是關(guān)鍵字(二分搜索)do{ k=(i+j)/ 2。elsesym= IDENT。do{num= 10 * num + ch39。}while(isdigit(ch))。){ getch()。getch()。){ getch()。getch()。} }// 漏掉空格,讀取一個(gè)字符void PL0::getch(){ if(cc == ll){if(feof(fin)){if(sym!=PERIOD)error(25)。fgets(line,lineLength,fin)。} ch= line[cc]。code[cx].l= y。if((sym)==()){error(n)。it++)(*it)。// data allocation index int tx0。// 表指針table[tx].= cx。do{constdeclaration(tx,dx,lev)。elseerror(5)。while(sym == COMMA){getsym()。}while(sym==IDENT)。} elseerror(4)。(SEMICOLON)。for(int i= IDENT。}symset tmp=statbegsys。code[table[tx0].].a= cx。gen(INT,0,dx)。statement(tmp,tx,lev)。listcode(cx0)。strcpy(table[tx].name,id)。}table[tx].=num。dx++。case ARRAY:table[tx]. = lev。i= tx。tx,intamp。sym{if(sym ==BECOMES)error(1)。}elseerror(2)。tx,intamp。}//vardeclaration end// 數(shù)組說明處理void PL0::arraydeclaration(intamp。if(sym == NUMBER || sym == CONSTSYM){if(num == 0){upscript = num。elseerror(32)。else { enter(ARRAY,tx,dx,downscript+1)。icout// 語句部分處理void PL0::statement(symset fsys,int tx,int lev){ if(sourceEnd)return。else if(table[i].kind!=VARIABLE){error(12)。elseerror(13)。} else if(sym == READSYM){ getsym()。elsei=0。}getsym()。}elsegetsym()。for(int t=RPAREN。}while(sym==COMMA)。} else if(sym ==CALLSYM){ getsym()。else if(table[i].kind = PROCEDURE)gen(CAL,levtable[i].,table[i].)。symset tmp=fsys。if(sym == THENSYM)getsym()。(ELSESYM)。if(sym == ELSESYM){getsym()。statement(fsys,tx,lev)。for(int i=SEMICOLON。(SEMICOLON)。getsym()。i((symbol)i)。tmp=fsys。if(sym ==SEMICOLON||sym ==ENDSYM)getsym()。statement(tmp,tx,lev)。} } else if(sym ==BEGINSYM){ getsym()。gen(JMP,0,0)。getsym()。cx1= cx。i((symbol)i)。getsym()。else {i= position(id,tx)。elsegetsym()。expression(tmp,tx,lev)。if(sym==LPAREN){do{getsym()。if(sym!= RPAREN){error(33)。else{gen(OPR,0,16)。elsedo{getsym()。if(sym!= SEMICOLON)error(10)。}getsym()。if(sym ==IDENT){i= position(id,tx)。} // 列出目標(biāo)代碼清單void PL0::listcode(int cx0)//list code generated for this block { int i。getsym()。}elseerror(32)。dx,int lev){int upscript=0,downscript=0。getsym()。} elseerror(4)。if(sym == NUMBER){enter(CONSTANT,tx,dx,lev)。if(sym=EQLamp。return i。} }//enter end// 查找標(biāo)示符在名字表中的位置int PL0::position(alfa id,int tx)//find identifier id in table { int i。case PROCEDURE:table[tx].=lev。case VARIABLE:table[tx].=lev。switch(k){ case CONSTANT:if(numamax){error(31)。tx,int amp。// return symset s2。for(int i=SEMICOLON。// start adr of code table[tx0].=dx。test(tmp,declbegsys,7)。test(tmp,fsys,6)。if(sym == SEMICOLON){getsym()。elseerror(5)。if(sym ==IDENT){enter(PROCEDURE,tx,dx,lev)。}if(sym ==SEMICOLON)getsym()。if(sym == VARSYM)// 處理變量聲明 { getsym()。constdeclaration(tx,dx,lev)。if(levlevmax)error(32)。// initial code indexdx= 3。} }//test end// 分程序分析處理過程void PL0::block(int lev,int tx,symset fsys){ if(sourceEnd)return。for(it=()。cx= cx+1。}// 生成目標(biāo)代碼,并送入目標(biāo)程序區(qū)void PL0::gen(fct x,int y,int z){ if(cx cxmax){coutreturn。ll=strlen(line)。return。} else// end of extra stuff { sym= ssym[ch]。=39。} else if(ch == 39。=39。} else if(ch == 39。k= k+1。num= 0。if(strcmp(id,word[k])=0)i= k+1。i= 1。 39。if(sourceEnd)return。memset(a,0,al+1)。while(ch ==39。(s+errStr[n])。// code line =fopen(source,”r“)。// 行緩沖區(qū)長度ch= 39。// 初始化項(xiàng)開始符號(hào)集合err= 0。strcpy(mnemonic[JPC],” jpc “)。strcpy(mnemonic[STO],” sto “)。]= SEMICOLON。39。// 初始化保留字表中每一個(gè)保// 初始化一些符號(hào)對(duì)應(yīng)的symbolssym[39。]= COMMA。=39。ssym[39。]= SLASH。*39。類型表ssym[39。memset(line,0,sizeof(line))。wsym[16]= WRITESYM。wsym[12]= THENSYM。wsym[8]= ODDSYM。wsym[4]= DOSYM。strcpy(word[16],”write“)。strcpy(word[12],”then“)。strcpy(word[8],”odd“)。strcpy(word[4],”do“)。// PL0構(gòu)造函數(shù)PL0::PL0(char* source,char*destination){ listswitch=true,sourceEnd=false。endif : include “”// 錯(cuò)誤字符串?dāng)?shù)組string PL0::errStr[]={“,”error 0001: 常數(shù)說明中“=”寫成“:=”“, ”error 0002: 常數(shù)說明中的“=”后應(yīng)為數(shù)字“, ”error 0003: 常數(shù)說明中的標(biāo)識(shí)符后應(yīng)是“=”“, ”error 0004: const,var,procedure后應(yīng)為標(biāo)識(shí)符“, ”error 0005: 漏掉了‘,’或‘。void interpret()。void condition(symset fsys,int tx,int lev)。void statement(symset fsys,int tx,int lev)。void vardeclaration(intamp。int position(alfa id,int tx)。合法void block(int lev,int tx,symset fsys)。位置和出錯(cuò)代碼void getsym()。// 符號(hào)表FILE* fin,*fout。// 保留字表中每一個(gè)保留字對(duì)應(yīng)的symbol類型symbol ssym[100]。// error array alfa a。// code allocation index int codeNo。// last number readint cc。char ch。int val。// 類PCODE指令類型,包含三個(gè)字段:指令f、層差l和另一個(gè)操作數(shù)a/******************************************* * lit 0,a: load constant a* * opr 0,a: execute operation a* * lod l,a: load variable l,a* * sto l,a: store variable l,a* * cal l,a: call procedure a at level l* * int 0,a: increment tregister by a* * jmp 0,a: jump to a* * jpc 0,a: jump conditional to a* *******************************************/typedef struct{ alfa name。// level,cann39。// 三種標(biāo)識(shí)符的類型 typedef enum {LIT,OPR,LOD,STO,CAL,INT,JMP,JPC} fct。// size of code array 類PCODE目標(biāo)代碼數(shù)組長度(可容納代碼行數(shù))const int lineLength = 82。// length of identifiers 標(biāo)示符的最大長度const int nmax = 14。五、相關(guān)代碼及運(yùn)行結(jié)果實(shí)驗(yàn)代碼; : include include include include include include ifn
點(diǎn)擊復(fù)制文檔內(nèi)容
黨政相關(guān)相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1