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

正文內(nèi)容

南開大學(xué)編譯原理第四章(已修改)

2025-01-30 19:01 本頁面
 

【正文】 第八章 中間代碼生成 學(xué)習(xí)內(nèi)容 ?三地址碼表示方法 ?聲明語句的翻譯 ?賦值語句的翻譯:數(shù)組尋址 ?布爾表達(dá)式的翻譯 ?case語句的翻譯 ?backpatching技術(shù)的實(shí)現(xiàn) ?過程調(diào)用的翻譯 中間語言 圖表示 a := b * c + b * c 語法樹方式表示 后綴表示 ——語法樹的線性表示方式 a b c uminus * b c uminus * + assign 語法制導(dǎo)定義構(gòu)造語法樹 PRODUCTION Semantic Rule S ? id := E { = mknode (‘a(chǎn)ssign’, mkleaf(id, ), ) } E ? E1 + E2 { = mknode(‘+’, ,) } E ? E1 * E2 { = mknode(‘*’, ,) } E ? E1 { = mknode(‘uminus’, ) } E ? ( E1 ) { = } E ? id { = mkleaf(id, ) } 語法樹的計(jì)算機(jī)內(nèi)部表示 三地址碼 ? ThreeAddress Code ?一般形式: x := y op z ?語法樹、 dag的線性化表示 t1 := c t1 := c t2 := b * t1 t2 := b * t1 t3 := c t5 := t2 + t2 t4 := b * t3 a := t5 t5 := t2 + t4 a := t5 三地址碼語句類型 1. 二元運(yùn)算: x := y op z 2. 一元運(yùn)算: x := op y 3. 復(fù)制語句: x := y 4. 無條件轉(zhuǎn)移: goto L 5. 條件轉(zhuǎn)移: if x relop y goto L 6. 函數(shù)調(diào)用: param x1 param x2 … param xn call p, n 7. 數(shù)組: x := y [i] , x [i] := y 8. 指針: x := amp。y, x := *y 語法制導(dǎo)翻譯生成三地址碼 ?賦值語句: id := E ?利用屬性 ? :保存 E的值的名字 ? :計(jì)算 E的三地址代碼 ?newtemp:生成臨時(shí)變量名 ?gen:輸出一條三地址碼指令 賦值語句的翻譯 PRODUCTION Semantic Rule S ? id := E { = || gen( ‘:=’ ) } E ? E1 + E2 {= newtemp 。 = || || || gen( ‘:=’ ‘+’ ) } E ? E1 * E2 {= newtemp 。 = || || || gen( ‘:=’ ‘*’ ) } E ? E1 {= newtemp 。 = || || gen( ‘:=’ ‘uminus’ ) } E ? ( E1 ) {= 。 = } E ? id { = 。 = ‘’ } 控制流語句的翻譯 ? while語句: S ? while E do S1 ?翻譯為 : if = 0 goto goto : ?語法制導(dǎo)定義: = newlabel。 = newlabel 。 = gen( ‘:’) || || gen(‘if’ ‘=’ ‘0’ ‘goto’ ) || || gen(‘goto’ ) || gen( ‘:’) 三地址碼的實(shí)現(xiàn) ?四元組,三元組 三元運(yùn)算的實(shí)現(xiàn) ——拆分 ?x[i] := y ?x := y[i] 間接三元組實(shí)現(xiàn)方式 聲明語句的翻譯 ? 過程內(nèi)部的聲明 PRODUCTION Semantic Rule P ? M D { } M ? ? {offset:=0 } D ? id : T { addtype(, , offset) offset:=offset + } T ? char { = char。 = 1。 } T ? integer { = integer 。 = 4。 } T ? array [ num ] of T1 {=array(,) = * } T ? ^T1 { = pointer()。 = 4} 作用域的處理 處理作用域的翻譯模式 P ? M D { addwidth(top(tblptr), top(offset))。 pop(tblptr)。 pop(offset) } M ? ? { t:=mktable(null)。 push(t, tblptr)。 push(0, offset)} D ? D1 。 D2 D ? proc id 。 N D 。 S { t:=top(tblpr)。 addwidth(t,top(offset))。 pop(tblptr)。 pop(offset)。 enterproc(top(tblptr), , t)} N ? ? {t:=mktable(top(tblptr))。 push(t,tblptr)。 push(0,offset)。} D ? id : T {enter(top(tblptr), , , top(offset))。 top(offset):=top(offset) + 符號表?xiàng)? 內(nèi)存占用量棧 記錄類型的處理 ?創(chuàng)建獨(dú)立的符號表 T→ record L D end { = record(top(tblptr))。 = top(offset)。 pop(tblptr)。 pop(offset)。 } L→ ? { t = mktable(null)。 push(t, tblptr)。 push(0, offset)。 } 賦值語句 符號表中的名字 S→ id := E { p = lookup()。 if (p != null) emit(p ‘:=’ )。 else error。 } E→ E 1 + E2 { = newtemp。 emit( ‘:=’ ‘+’ 。 } E→ E 1 * E2 { = newtemp。 emit( ‘:=’ ‘*’ 。 } E→ E1 { = newtemp。 emit( ‘:=’ ‘uminus’ 。 } E→ ( E 1 ) { = } E→
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫吧 www.dybbs8.com
公安備案圖鄂ICP備17016276號-1