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

正文內(nèi)容

編譯原理課程設(shè)計ll遞歸下降分析器-閱讀頁

2024-10-29 06:36本頁面
  

【正文】 umbers 數(shù)字的最大長度 const int amax = 2047。// maximum depth of block nesting 最大允許的塊嵌套層數(shù) const int cxmax = 200。// 行緩沖區(qū)長度typedef enum {NUL,IDENT,NUMBER,PLUS,MINUS,TIMES,SLASH,ODDSYM,EQL,NEQ,LSS,LEQ,GTR,GEQ,LPAREN,RPAREN,COMMA,SEMICOLON,PERIOD,BECOMES,BEGINSYM,ENDSYM,IFSYM,THENSYM,WHILESYM,WRITESYM,READSYM,DOSYM,CALLSYM,CONSTSYM,VARSYM,PROCSYM,ELSESYM,REPEATSYM,UNTILSYM} symbol。// alfa類型用于標識符 typedef enum {CONSTANT,VARIABLE,PROCEDURE,ARRAY} obj0。// functions typedef set symset。// function code int l。t big than levmaxint a。t big than amax }。obj0 kind。}inOther。}other。class PL0 {protected:bool listswitch,sourceEnd。// last character read symbol sym。// last identifier read int num。// character count int ll。int cx。// code line string errStr[]。// code line vector errorString。// 詞法分析器中用于臨時存放正在分析的詞instruction code[cxmax+1]。// 保留字表symbol wsym[norw+1]。// 一些符號對應(yīng)的symbol類型表合 char mnemonic[8][6]。// 聲明開始、表達式開始和項開始符號集 Table table[txmax+1]。public:PL0(char* source,char*destination)。}void error(int n)。個單詞void getch()。程序區(qū)void test(symset s1,symset s2,int n)。void enter(obj0 k,int amp。dx,int lev)。的位置void constdeclaration(intamp。dx,int lev)。tx,intamp。void listcode(int cx0)。void expression(symset fsys,int tx,int lev)。void factor(symset fsys,int tx,int lev)。void arraydeclaration(intamp。 dx,int lev)。執(zhí)行程序int base(int l,int b,int s[])。// 構(gòu)造函數(shù)// 析構(gòu)函數(shù)// 出錯處理,打印出錯// 詞法分析,讀取一// 漏掉空格,讀取一// 生成目標代碼,并送入目標// 測試當前單詞符號是否// 分程序分析處理過程// 登入名字表// 查找標示符在名字表中// 常量定義處理// 變量說明處理// 列出目標代碼清單// 語句部分處理// 表達式處理// 項處理// 因子處理// 條件處理// 數(shù)組說明處理// 對目標代碼的解釋// 通過靜態(tài)鏈求出數(shù)據(jù)區(qū)的 // 保存代碼}。’“, ”error 0006: 過程說明后的符號不正確(應(yīng)是語句開始符或過程開始符)“, ”error 0007: 應(yīng)是語句開始符“, ”error 0008: 過程體內(nèi)語句部分的后跟符不正確“, ”error 0009: 程序皆為丟了句號‘.’“, ”error 0010: 語句之間漏了‘?!? ”error 0018: while型循環(huán)語句中丟了do“, ”error 0019: 語句后的標識符不正確“, ”error 0020: 應(yīng)為關(guān)系運算符“, ”error 0021: 表達式內(nèi)標識符屬性不能是過程“, ”error 0022: 表達式中漏掉了右括號‘)’“, ”error 0023: 因子后的非法符號“, ”error 0024: 表達式開始符不能是此符號“, ”error 0025: 文件在不該結(jié)束的地方結(jié)束了“, ”error 0026: 結(jié)束符出現(xiàn)在不該結(jié)束的地方“, ”error 0027: “,”error 0028: “,”error 0029: “,”error 0030: “, ”error 0031: 數(shù)越界“, ”error 0032: read語句括號中標識符不是變量“, ”error 0033: else附近錯誤“ , ”error 0034: repeat附近錯誤“}。strcpy(word[1],”begin“)。strcpy(word[3],”const“)。strcpy(word[5],”else“)。strcpy(word[7],”if“)。strcpy(word[9],”procedure“)。strcpy(word[11],”repeat“)。strcpy(word[13],”until“)。strcpy(word[15],”while“)。wsym[1]= BEGINSYM。留字對應(yīng)的symbol類型wsym[3]= CONSTSYM。wsym[5]= ELSESYM。wsym[7]= IFSYM。wsym[9]= PROCSYM。wsym[11]= REPEATSYM。wsym[13]= UNTILSYM。wsym[15]= WHILESYM。memset(code,0,sizeof(code))。memset(table,0,sizeof(table))。ssym[39。]= PLUS。39。ssym[39。]= TIMES。/39。ssym[39。]= LPAREN。)39。ssym[39。]= EQL。,39。ssym[39。]= PERIOD。39。ssym[39。]= GTR。39。strcpy(mnemonic[LIT],” lit “)。strcpy(mnemonic[LOD],” lod “)。strcpy(mnemonic[CAL],” cal “)。strcpy(mnemonic[JMP],” jmp “)。(CONSTSYM),(VARSYM),(PROCSYM)。// (IDENT),(NUMBER),(LPAREN)。cc= 0。// 代碼分配指針,代碼生成模塊總在cx所指位置生成新的代碼ll= 0。 39。// 引入此變量是出于程序性能考慮 codeNo=0。fout=fopen(destination,”w“)。sprintf(s,”第 %d 行:“,codeNo)。err= err+1。int i,j,k。 39。// cls space and tab if(isalpha(ch))// id or reserved word {k=0。// 檢測一個單詞長度 do{ if(k al){a[k]= ch。} getch()。}while(isalpha(ch)||isdigit(ch))。else { do{a[kk]= 39。kk= kk1。} strcpy(id,a)。j= norw。if(strcmp(id, word[k])j= k1。}while(i j)sym= wsym[k]。} else if(isdigit(ch))// number { k= 0。sym= NUMBER。039。getch()。if(k nmax)error(30)。:39。if(ch == 39。){sym= BECOMES。} elsesym= NUL。// extra stuff added to support 39。if(ch == 39。){sym= GEQ。} elsesym= GTR。// 其它符號的賦值getch()。sourceEnd=true。}cc= 0。codeNo++。if(line[ll1]==10)ll。cc= cc+1。}code[cx].f= x。code[cx].a= z。}//gen end// 測試當前單詞符號是否合法void PL0::test(symset s1,symset s2,int n){ if(sourceEnd)return。symset::iterator it。it!=()。//s1=s1+s2while((sym)==())getsym()。int dx。// initial table index int cx0。// 變量的個數(shù) tx0= tx。gen(JMP,0,0)。do{if(sym == CONSTSYM)// 處理常量聲明{getsym()。while(sym == COMMA){}getsym()。} if(sym ==SEMICOLON)getsym()。}while(sym==IDENT)。do{vardeclaration(tx,dx,lev)。vardeclaration(tx,dx,lev)。elseerror(5)。} while(sym ==PROCSYM)// 處理過程的聲明 { getsym()。getsym()。if(sym ==SEMICOLON)getsym()。symset tmp = fsys。block(lev+1,tx,tmp)。symset tmp = statbegsys。i((symbol)i)。}elseerror(5)。(IDENT)。}while((sym)!=())。table[tx0].= cx。cx0= cx。symset tmp=statbegsys。i ((symbol)i)。gen(OPR,0,0)。test(fsys,s2,8)。}// block end// 登入名字表void PL0::enter(obj0 k,int amp。dx,int lev){ tx= tx+1。table[tx].kind=k。num=0。break。table[tx].=dx。break。break。break。strcpy(table[0].name, id)。while(strcmp(table[i].name,id)!=0)i。}//position end// 常量定義處理void PL0::constdeclaration(intamp。dx,int lev){ if(sym == IDENT){getsym()。amp。getsym()。getsym()。}elseerror(3)。}// constdeclaration end// 變量說明處理void PL0::vardeclaration(intamp。dx,int lev){ if(sym == IDENT){enter(VARIABLE,tx,dx,lev)。} elseerror(4)。tx,intamp。getsym()。getsym()。} if(sym == COMMA)getsym()。if(sym == NUMBER || sym == CONSTSYM){downscript = num。} if(sym!= RPAREN)} error(32)。getsym()。if(listswitch)for(i= cx0。int i,cx1,cx2。if(i == 0)error(11)。i= 0。if(sym ==BECOMES)getsym()。expression(fsys,tx,lev)。if(i!= 0)gen(STO,levtable[i].,table[i].)。if(sym!=LPAREN)error(34)。if(sym==IDENT)i=position(id,tx)。if(i==0)error(35)。gen(STO,levtable[i].,table[i].)。}while(sym == COMMA)。while((sym)!=())getsym()。} else if(sym == WRITESYM){ getsym()。symset tmp=fsys。t((symbol)t)。gen(OPR,0,14)。if(sym!=RPAREN)error(33)。} gen(OPR,0,15)。if(sym!=IDENT)error(14)。if(i == 0)error(11)。elseerror(15)。} } else if(sym ==IFSYM){ getsym()。for(int i = THENSYM。condition(tmp,tx,lev)。elseerror(16)。gen(JPC,0,0)。statement(tmp,tx,lev)。code[cx1].a= cx。cx2=cx。code[cx1].a=cx。code[cx2].a=cx。symset tmp=fsys。i((symbol)i)。tmp=statbegsys。while((sym)!=()){if(sourceEnd)return。else if(sym=PERIOD){error(26)。}elseerror(10)。for(i=SEMICOLON。if(sourceEnd)re
點擊復(fù)制文檔內(nèi)容
黨政相關(guān)相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1