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

正文內容

word版可編輯-編譯原理課程設計實驗報告川大張兵精心整理(存儲版)

2025-08-14 12:35上一頁面

下一頁面
  

【正文】 cmp(c,!=)) { to=budengyu。 } else if(!strcmp(c,])) { to=youzhongkuohao。//token序列void scan(){ int i,j,m,l,n。39。39。(39。{39。ik1。amp。//注釋結束 } continue。s[i][j]=39。))//字母 { l=j。)||(s[i][l]=39。\039。 strcpy(,t)。 strcpy(,t)。s[i][j]=39。s[i][l]=39。 =gettokentype(linshi)。//標記 for(m=0。\039。 strcpy(,t)。m++) { token to。 printf( %d: special characters: %c\n,i+1,t[m])。//節(jié)點種類typedef enum{ Void,Integer}Exptype。//當前tokentoken lasttoken。//打印空格void printtree(treenode * t)。//簡單表達式treenode * varr()。//復合語句體后者treenode * local_declaration()。//語法分析void gettoken()//得到token{ lasttoken=currenttoken。 }}void printspace(int n)//打印空格{ int i。 } else if(tnodekind==nums) { printf(num:%s\n,tnodestring)。 } else if(tnodekind==whiles) { printf(while\n)。 } blank++。 plineno=。 if(!=youkuohao) { p=expression()。 } } } } if(p!=NULL) { tchild=p。 match(youkuohao)。 match(youkuohao)。 } } return t。 } return t。 } return t。 } return t。 match(youzhongkuohao)。 } else { treenode * p=NULL。}treenode * expression_stmt()//表達式聲明{ treenode * t=NULL。 return t。 } match(youkuohao)。 if(tchild!=NULL) (tchild)brother=statement()。 if(t!=NULL) { tchild=expression()。 match(zuokuohao)。 match(returnn)。 } else { t=simple_expression(t)。}treenode * expression()//表達式{ treenode * t=varr()。 if(==zuozhongkuohao) { match(zuozhongkuohao)。 (qchild)brother=additive_expression(k)。 (qchild)brother=term(k)。 (qchild)brother=factor(k)。 parseerror()。 } } else { if(==zuokuohao) { match(zuokuohao)。 return t。 } else { qbrother=s。 treenode * p=NULL。 } else { pchild=NULL。 } else if(tnodekind==hanshudiaoyongcanlist) { printf(hanshudiaoyongcanlist\n)。 } else if(tnodekind==fuheyuju) { printf(fuheyuju\n)。 } else if(tnodekind==voids) { printf(void\n)。 } else { coutmatch errorendl。//函數(shù)聲明treenode * declaration_list()。//if聲明treenode * statement()。treenode * additive_expression(treenode * k)。//匹配treenode * pound_stmt()。//節(jié)點類型所代表的字符串,用于語法樹打印}。 (to)。 =i+1。 } } if(flag)//單目符號 { for(m=0。m++)//雙目比較符 { if(!strcmp(t,sp[m])) { token to。 } } if(!flag) { break。 n=0。 token to。amp。amp。 strcpy(linshi,id)。 token to。)) { t[m++]=s[i][l++]。s[i][l]=39。s[i][j]=39。amp。/39。jlen。//單目符號 zs=0。]39。,39。39。+39。 } return to。 } else if(!strcmp(c,))) { to=youkuohao。 } else if(!strcmp(c,=)) { to=dayudengyu。 } else if(!strcmp(c,while)) { to=whilee。//token串 int lineno。/39。*39。i++) { len=strlen(s[i])。char t[1005]。首先自己對遞歸向下分析法進行了學習,將書上的幾個遞歸向下分析的偽代碼看過之后,自己對遞歸向下的分析方法的原理有了初步的認識,大概知道了根據(jù)文法怎么分析。如果是IF則是if語句類型,如果是WHILE,則是while語句類型,如果是RETURN,則是return語句類型,如果是左大括號,則是復合語句類型,如果是ID、SEMI、LPAREN、NUM,則是表達式語句類型代碼treenode * statement()待分析文法expressionstmt→ [expression]。所以vardeclaration和fundeclaration文法在declaration→vardeclaration|fundeclaration文法中就都已經分析了代碼treenode * declaration()待分析文法params→param_list | void分析函數(shù)treenode * params()分析說明函數(shù)參數(shù)列表要么是void,要么是多個參數(shù)組成。selectionstmt→if (expression) statement [else statement]iterationstmt→while (expression)statementreturnstmt→return [expression]。//兄弟節(jié)點 int lineno。//函參treenode * param_list(treenode * k)。treenode * expression_stmt()。//創(chuàng)建新節(jié)點treenode * args()。//token下標int blank=0。、,、(、)、[、]、{、}、num、id、錯誤、結束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。如果不存在注釋錯誤,則調用scan()函數(shù)進行詞法分析,否則報錯。要求:實現(xiàn)scanner和parser功能分析與設計語法分析采用遞歸下降方法的程序結構:本程序采用面向對象的思想編寫,使用C語言實現(xiàn),程序分為兩部分:詞法分析(scan)和語法分析(parse),分別將兩個處理階段寫在兩個函數(shù)中,分別是scan()和parse(),兩個函數(shù)分別完成詞法分析和語法分析的任務。所以在分析的同時,就會將所分析出的token輸出 token結構體定義如下:struct token//token結構體{ Tokentype tokentype。語法分析階段的代碼中,每一條文法都有相對應的函數(shù),通過函數(shù)之間的遞歸調用來達到語法分析的目的。//輸出錯誤void match(Tokentype tt)。treenode * term(treenode * k)。//while聲明treenode * selection_stmt()。//函數(shù)參數(shù)treenode * declaration()。//節(jié)點類型所代表的字符串,用于語法樹打印}。parse(void)函數(shù)使用遞歸向下分析方法直接調用declaration_list()函數(shù),并返回樹節(jié)點代碼treenode * parse()待分析文法declaration_list → declaration{ declaration }分析函數(shù)treenode * declaration_list()分析說明C語言編寫的程序由一組聲名序列組成。param(TreeNode * k)函數(shù)根據(jù)探測先行Token是int還是void而新建IntK或VoidK節(jié)點作為其第一個子節(jié)點,然后新建IdK節(jié)點作為其第二個子節(jié)點,最后探測Follow集合,是否是中括號,而確定是否再
點擊復制文檔內容
職業(yè)教育相關推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1