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

正文內(nèi)容

word版可編輯-編譯原理課程設(shè)計(jì)實(shí)驗(yàn)報(bào)告川大張兵精心整理(編輯修改稿)

2025-08-11 12:35 本頁面
 

【文章內(nèi)容簡(jiǎn)介】 于C語言給出的文法有左遞歸存在,于是自己將存在左遞歸的文法改寫成EBNF的形式,并據(jù)此進(jìn)行代碼編寫。整個(gè)過程可以說是痛并快樂著,一方面自己在編寫代碼的時(shí)候遇到了很多問題,這也是自己動(dòng)手能力不足的一個(gè)表現(xiàn)。 在詞法分析方面,使用全局變量zs來判斷當(dāng)前字符是否是注釋,并且通過zs的值判斷注釋是否合法。整體來說,代碼簡(jiǎn)介明了,沒有復(fù)雜的類的關(guān)系,樹節(jié)點(diǎn)只有孩子和兄弟兩個(gè)子節(jié)點(diǎn),沒有復(fù)雜的節(jié)點(diǎn)之間的關(guān)系。 由于各函數(shù)之間邏輯關(guān)系比較復(fù)雜,代碼還存在一些錯(cuò)誤,需要通過測(cè)試來修復(fù)bug程序代碼實(shí)現(xiàn)includecstdioincludecstringincludecmathincludealgorithmincludeiostreamincludestringincludevectorusing namespace std。char s[1005][1005]。//文本char p[1005][1005]。char t[1005]。//當(dāng)前token串char linshi[1100]。//臨時(shí)數(shù)組int k。//文本行數(shù)int zs。//注釋標(biāo)記,1表示是注釋,0表示不是注釋void zhushierror()//注釋錯(cuò)誤{ int i,j,len。 zs=0。 for(i=0。ik1。i++) { len=strlen(s[i])。 for(j=0。jlen1。j++) { if(s[i][j]==39。/39。amp。amp。s[i][j+1]==39。*39。) { if(zs==0) { zs=1。 } else { return。 } } if(s[i][j]==39。*39。amp。amp。s[i][j+1]==39。/39。) { if(zs==1) { zs=0。 } else { zs=1。 return。 } } } }}//定義的Token的類型(29種),分別對(duì)應(yīng)于else、if、int、return、void、while、//+、*、/、=、=、==、/////!=、=、。、,、(、)、[、]、{、}、num、id、錯(cuò)誤、結(jié)束typedef enum{ elsee=1,iff,intt,returnn,voidd,whilee,xiaoyudengyu,dayudengyu,dengyudengyu,budengyu,//10 jia,jian,cheng,chu,dayu,xiaoyu,dengyu,fenhao,douhao,zuokuohao,youkuohao,zuozhongkuohao,//22 youzhongkuohao,zuohuakuohao,youhuakuohao,num,id,error,end//29}Tokentype。struct token//token結(jié)構(gòu)體{ Tokentype tokentype。//token類型 char tokenstring[1100]。//token串 int lineno。//token行號(hào)}。Tokentype gettokentype(char c[]){ Tokentype to。 if(!strcmp(c,else)) { to=elsee。 } else if(!strcmp(c,if)) { to=iff。 } else if(!strcmp(c,return)) { to=returnn。 } else if(!strcmp(c,int)) { to=intt。 } else if(!strcmp(c,void)) { to=voidd。 } else if(!strcmp(c,while)) { to=whilee。 } else if(!strcmp(c,+)) { to=jia。 } else if(!strcmp(c,)) { to=jian。 } else if(!strcmp(c,*)) { to=cheng。 } else if(!strcmp(c,/)) { to=chu。 } else if(!strcmp(c,)) { to=xiaoyu。 } else if(!strcmp(c,=)) { to=xiaoyudengyu。 } else if(!strcmp(c,)) { to=dayu。 } else if(!strcmp(c,=)) { to=dayudengyu。 } else if(!strcmp(c,==)) { to=dengyudengyu。 } else if(!strcmp(c,!=)) { to=budengyu。 } else if(!strcmp(c,=)) { to=dengyu。 } else if(!strcmp(c,。)) { to=fenhao。 } else if(!strcmp(c,)) { to=douhao。 } else if(!strcmp(c,()) { to=zuokuohao。 } else if(!strcmp(c,))) { to=youkuohao。 } else if(!strcmp(c,[)) { to=zuozhongkuohao。 } else if(!strcmp(c,])) { to=youzhongkuohao。 } else if(!strcmp(c,{)) { to=zuohuakuohao。 } else if(!strcmp(c,})) { to=youhuakuohao。 } else if(!strcmp(c,num)) { to=num。 } else if(!strcmp(c,id)) { to=id。 } else if(!strcmp(c,end)) { to=end。 } return to。}vectortoken tokenlist。//token序列void scan(){ int i,j,m,l,n。//下標(biāo) int f,flag。//標(biāo)記 int len。//當(dāng)前行長(zhǎng)度 char guan[10][1005]={else,if,int,return,void,while}。//關(guān)鍵字 char sp[10][1005]={=,=,==,!=}。//雙目比較符 char fu[1005]={39。+39。,39。39。,39。*39。,39。/39。,39。39。,39。39。,39。=39。,39。39。,39。,39。,39。(39。,39。)39。,39。[39。,39。]39。,39。{39。,39。}39。,39。!39。}。//單目符號(hào) zs=0。 for(i=0。ik1。i++) { len=strlen(s[i])。 printf(%d: ,i+1)。 printf(%s\n,s[i])。 if(len==0)//空行 { continue。 } for(j=0。jlen。j++) { if(zs)//注釋 { if(j=1amp。amp。s[i][j1]==39。*39。amp。amp。s[i][j]==39。/39。) { zs=0。//注釋結(jié)束 } continue。 } if(s[i][j]==39。 39。)//空格 { continue。 } if((s[i][j]=39。z39。amp。amp。s[i][j]=39。a39。)||(s[i][j]=39。Z39。amp。amp。s[i][j]=39。A39。))//字母 { l=j。 m=0。 while((s[i][l]=39。z39。amp。amp。s[i][l]=39。a39。)||(s[i][l]=39。Z39。amp。amp。s[i][l]=39。A39。)) { t[m++]=s[i][l++]。 } t[m]=39。\039。 f=1。//標(biāo)記 for(n=0。n=5。n++) { if(!strcmp(t,guan[n])) { f=0。 printf( %d: reserved word: %s\n,i+1,t)。 token to。 =gettokentype(t)。 strcpy(,t)。 =i+1。 (to)。 break。 } } if(f) { printf( %d: ID, name= %s\n,i+1,t)。 token to。 strcpy(linshi,id)。 =gettokentype(linshi)。 strcpy(,t)。 =i+1。 (to)。 } j=l1。 } else if(s[i][j]=39。939。amp。amp。s[i][j]=39。039。)//數(shù)字 { l=j。 m=0。 while((s[i][l]=39。939。
點(diǎn)擊復(fù)制文檔內(nèi)容
職業(yè)教育相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖片鄂ICP備17016276號(hào)-1