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

正文內(nèi)容

編譯技術(shù)課程設(shè)計報告-詞法分析、語法分析、中間代碼生成-在線瀏覽

2024-07-25 13:32本頁面
  

【正文】 F’ → **F|ε P→ (E)|i ( 3)數(shù)據(jù)結(jié)構(gòu) 與 函數(shù)說明 在 main 函數(shù)調(diào)用 E()函數(shù),如果調(diào)用之后返回時 ,如果 ((flags[temp]==0)amp。is_right) 為真,就輸出“分析成功”,否則輸出“分析失敗”。 E 函數(shù) : 調(diào)用 T 函數(shù),調(diào)用 F 函數(shù) , 調(diào)用 P 函數(shù) ,返回后看是否是’ +’或’ ’,如 果是,則調(diào)用 E1 函數(shù),再調(diào)用 E2函數(shù),如果不是,進行出錯處理,置 is_right 為 0。 代碼: void E() { coutETE39。endl。 E2()。+Tendl。 T()。Tendl。 T()。 } void E2() { if(flags[temp]==9||flags[temp]==12)//如果是加或減 { coutE39。E39。39。 E1()。 } else if (flags[temp]!=0||flags[temp]!=17)//如果是非 或非 { coutE39。ε endl。 } else is_right=0。 T1 函數(shù):判斷是不是” *”或者“ /” 如果是,調(diào)用 F 函數(shù),如果不是,進行出錯 處理,置 is_right 為 0。39。 F()。 } void T1() { if(flags[temp]==10) //乘號 { coutT39。 temp++。 } else if(flags[temp]==13) //除號 { coutT39。 temp++。 } else is_right=0。39。T39。endl。 T2()。39。 return 。 } F 函數(shù):調(diào)用 P 函數(shù), F1 函數(shù)。 代碼: void F() { coutFPF39。 P()。 } void F1() { if(flags[temp]==11) //乘 ?方 ? { coutF39。 temp++。 } Elseif(flags[temp]!=0amp。flags[temp]!=17amp。flags[temp]!=9amp。flags[temp]!=12amp。f lags[temp]!=10amp。flags[temp]!=13)//非 非)非 +非 非 *非 / { coutF39。 is_right=0。如果是,調(diào)用 E函數(shù),返回后檢查是否是’ )’ ,如果不是,進行出錯處理,置 is_right為 0。 代碼 : void P() { if(flags[temp]==6||flags[temp]==7) //標識符或常數(shù) { coutPiendl。 } else if(flags[temp]==17) //( { coutP(E)endl。 E()。 temp++。 } else is_right =0。 temp 用來存放數(shù)組的下表,在主程序中語法分析結(jié)束后,置 0. 定義函數(shù) newtemp()用于門生一個新的臨時變量的名字,具體實現(xiàn)時每 產(chǎn)生一個 T,就及時送到符號表中,也可以不進符號表,直接將單詞值用整 數(shù)碼表示。 定義函數(shù) YE() 進行 中間代碼生成 ( 3) 流程圖 第 12 頁 五、 程序運行 結(jié)果 注:本程序?qū)τ谛稳?a1 的標識符無法作為整體識別 詞法測試: 表達式正確: 2*3+4/( as5) **6 第 13 頁 詞法分析: 第 14 頁 語法分析 第 15 頁 四元式: 表達式錯誤: 2*( 32 第 16 頁 六、總結(jié) 這次課程設(shè)計使我對編譯原理有了進一步的了解,更加鞏固了所學習的知識。編譯這個概念有一定的了解。 程序代碼: //include include iostream includestring using namespace std。 /*status which is use to judge the string is keywords or not!*/ char ch。 char program[500]。 //存儲輸入句子 string t[500]。 //數(shù)組下標 int is_right。 //關(guān)鍵字 number=0。 j=0。 //遍歷 if ((ch = 39。) amp。 (ch = 39。 )||(ch=39。)amp。(ch=39。)) //字母 { while ((ch = 39。) amp。 (ch = 39。 )||(ch=39。)amp。(ch=39。)) { words[j++]=ch。 } 第 17 頁 i。\039。 k 5。 status = 1。 } case 1:{ flag = 2。 break。 status = 1。 } case 3:{ flag = 4。 break。 status = 1。 } } if (status == 0) { flag = 6。039。amp。939。 while ((ch = 39。 ) amp。 (ch = 39。 )) { number = number*10+(ch39。)。 第 18 頁 } flag = 7。 } else switch (ch) //運算符和標點符號 { case 39。:{ if (ch == 39。) words[j++] = ch。\039。 if (ch == 39。) { words[j++] = ch。\039。 } else { i。 } break。39。39。 words[j] = 39。 ch = program[i++]。=39。 words[j] = 39。 flag =14。 flag = 14。 } 第 19 頁 case39。:{ if (ch == 39。) words[j++] = ch。\039。 if (ch == 39。) { words[j++] = ch。\039。 } else { i。 } break。!39。!39。 words[j] = 39。 ch = program[i++]。=39。 words[j] = 39。 flag = 14。 flag = 18。 } case39。:{ if (ch == 39。) words[j++] = ch。\039。 if (ch == 39。) 第 20 頁 { words[j++] = ch。\039。 } else if (ch == 39。) { words[j++] = ch。\039。 } else { i。 } break。39。39。 words[j] = 39。 ch = program[i++]。=39。 words[j] = 39。 flag = 12。39。 words[j] = 39。 flag = 12。 flag = 12。 } 第 21 頁 case39。:{ if (ch == 39。) words[j++] = ch。\039。 if (ch == 39。) { words[j++] = ch。\039。 } else { i。 } break。/39。/39。 words[j] = 39。 ch = program[i++]。=39。 words[j] = 39。 flag = 13。 flag = 13。 } case39。:{ words[j] = ch。\039。 break。(39。 words[j+1] = 39。 flag = 17。 } case39。:{ words[j] = ch。\039。 break。[39。 words[j+1] = 39。 flag = 21。 } case39。:{ words[j] = ch。\0
點擊復(fù)制文檔內(nèi)容
研究報告相關(guān)推薦
文庫吧 www.dybbs8.com
備案圖鄂ICP備17016276號-1