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

正文內(nèi)容

第7章語(yǔ)義分析與中間代碼生成-文庫(kù)吧資料

2024-10-19 22:23本頁(yè)面
  

【正文】 } : . . . (d) S1。 S2 {:=newlabel。 := 。 := newlabel。 := 。 := newlabel。 := 。 S2 圖 ifthen、 ifthenelse和 whiledo語(yǔ)句的目標(biāo)代碼結(jié)構(gòu) 2020/11/17 78 常見控制結(jié)構(gòu)的翻譯 S ? if B then S1 { := newlabel。,它是 S的代碼執(zhí)行后應(yīng)執(zhí)行的第一個(gè)三地址碼指令的標(biāo)號(hào)。)} 2020/11/17 74 例 對(duì) ab or cd and ef的翻譯 100: if ab goto 103 107: t2 := 1 101: t1:= 0 108: if ef goto 111 102: goto 104 109: t3 := 0 103: t1 := 1 110: goto 112 104: if cd goto 107 111: t3 := 1 105: t2 := 0 112: t4 := t2 and t3 106: goto 108 113: t5 := t1 or t4 2020/11/17 75 常見控制結(jié)構(gòu)的翻譯 ? 文法 ? S → if B then S1 ? S → if B then S1 else S2 ? S → while B do S1 ? S → begin Slist end ? Slist →Slist。39。 gencode( 39。139。:= 39。)} B ? true {:= newtemp。39。 gencode( 39。goto39。) 。39。 gencode( 39。goto39。 gencode(39。not39。:= 39。)} B ? not B1 { := newtemp。:=39。)} B ? B1 and B2 { := newtemp。:=39。 … ;語(yǔ)句 end ? 分支結(jié)構(gòu) if_then_else、 if_then switch、 case ? 循環(huán)結(jié)構(gòu) while_do、 do_while for、 repeat_until ? goto語(yǔ)句 ? 三地址碼 ? goto n (j, _, _, n) ? if x relop y goto n (jrelop, x, y, n) 2020/11/17 70 布爾表達(dá)式的翻譯 ? 基本文法 B ? B1 or B2 | B1 and B2 | not B1 | (B1) | E1 relop E2 | true | false ? 處理方式 ? 數(shù)值表示法 (與算術(shù)表達(dá)式的處理類似 ) ? 真: = 1 ? 假: = 0 ? 真假出口表示法 (作為其他語(yǔ)句的條件改變控制流程,隱含著程序中的 位置 ) ? 真出口: ? 假出口: 2020/11/17 71 布爾表達(dá)式的翻譯 ? a or b and not c ? t1:=not c ? t2:=b and t1 ? t3:=a or t2 ? ab ? 100: if ab goto 103 ? 101: t:=0 ? 102: goto 104 ? 103: t:=1 ? 104 2020/11/17 72 用數(shù)值表示布爾值的翻譯 ? nextquad是下一條三地址碼指令的序號(hào),每生成一條三地址碼指令 gencode便會(huì)將 nextquad加 1 B ? B1 or B2 { := newtemp。 gencode(,‘:=’,u,‘real+’,)。 = integer end else if = integer and = real then begin u := newtemp。 gencode(,‘:=’,‘+’,)} E ? (E1) { := } S ? Left := E {if =null then /?Left是簡(jiǎn)單變量 ?/ gencode(, ‘:= ’, ) else gencode(,‘[’,‘]’,‘:=’,)} ((i1*n2)+i2)*w+(base(low1* n2 low2)*w) ((i1*n2)+i2)*w+(base(low1* n2 low2)*w) 2020/11/17 60 例:設(shè) A是一個(gè) 10 20的整型數(shù)組 ——w=4 S := := x := null x := t4 := t2 := t3 := t1 := 2 := A , := y := 1 := A := z := z := null := y := y := null A [ z ] y x := A[ y, z ]的注釋分析樹 2020/11/17 61 例 S := := x := null x := t4 := t2 := t3 := t1 := 2 := A , := y := 1 := A := z := z := null := y := y := null A [ z ] y x := A[ y, z ]的注釋分析樹 t1 := y ? 20 t1 := t1 + z 2020/11/17 62 例 S := := x := null x := t4 := t2 := t3 := t1 := 2 := A , := y := 1 := A := z := z := null := y := y := null A [ z ] y x := A[ y, z ]的注釋分析樹 t1 := y ? 20 t1 := t1 + z t2 :=baseA? 84 t3 := 4 ? t1 2020/11/17 63 例 S := := x := null x := t4 := t2 := t3 := t1 := 2 := A , := y := 1 := A := z := z := null := y := y := null A [ z ] y x := A[ y, z ]的注釋分析樹 t1 := y ? 20 t1 := t1 + z t4 := t2 [t3 ] t2 :=baseA? 84 t3 := 4 ? t1 2020/11/17 64 例 S := := x := null x := t4 := t2 := t3 := t1 := 2 := A , := y := 1 := A := z := z := null := y := y := null A [ z ] y x := A[ y, z ]的注釋分析樹 t1 := y ? 20 t1 := t1 + z t4 := t2 [t3 ] x := t4 t2 :=baseA? 84 t3 := 4 ? t1 2020/11/17 65 類型檢查 ? 類型檢查具有發(fā)現(xiàn)程序錯(cuò)誤的能力 , 為了進(jìn)行類型檢查 , 編譯程序需要為源程序的每個(gè)語(yǔ)法成分賦予一個(gè)類型表達(dá)式 , 名字的類型表達(dá)式保存在符號(hào)表中 , 其他語(yǔ)法成分 (如表達(dá)式 E或語(yǔ)句 S)的類型表達(dá)式則作為文法符號(hào)的屬性保存在語(yǔ)義棧中 。 gencode(,‘:=’,‘?’,w)} i1*n2 (i1*n2)+i2 ((i1*n2)+i2)*w base(low1* n2 low2)*w 2020/11/17 59 賦值語(yǔ)句的翻譯模式 E ? Left {if = null then /? Left是簡(jiǎn)單變量 ?/ := else begin := newtemp。 := newtemp。 := t。 gencode(t,‘:=’,t,‘+’,)。 m:=+1。 := 1。 ? 函數(shù) ? limit(array, j),返回 nj 2020/11/17 57 帶有數(shù)組引用的賦值語(yǔ)句的翻譯 S ? Left := E E ? E + E E ? (E) E ? Left Left ? Elist] Left ? id Elist ? Elist,E Elist ? id[E 2020/11/17 58 賦值語(yǔ)句的翻譯模式 Left?id { :=。 ? ,用來(lái)記錄 Elist中下標(biāo)表達(dá)式的個(gè)數(shù),即數(shù)組的維數(shù)。 ? 于是我們就可以為非終結(jié)符 Elist引進(jìn)一個(gè)綜合屬性,用來(lái)記錄指向符號(hào)表中相應(yīng)數(shù)組名字表項(xiàng)的指針。每當(dāng)臨時(shí)變量?jī)H作為運(yùn)算對(duì)象使用時(shí), c減去 1;每當(dāng)要求產(chǎn)生新的臨時(shí)名字時(shí),使用 $c并把 c增加 1。 emit(,‘:=’,‘uminus’,)} E ? (E1) { := } E ? id {p := lookup()。 if p ? nil then gencode( p, ‘:=’, ) else error } E ? E1 + E2{ := newtemp。 push(t,tblprt)。 pop(tblptr)。 xx yy nn ee xx tt 0 4 8 2020/11/17 45 記錄的翻譯 ? 符號(hào)表及有關(guān)表格處理 ? 為每個(gè)記錄類型單獨(dú)構(gòu)造一張符號(hào)表 ? 將域名 id的信息 (名字、類型、字節(jié)數(shù) )填入到該記錄的符號(hào)表中 ? 所有域都處理完后, offset將保存記錄中所有數(shù)據(jù)對(duì)象的寬度總和 ? record應(yīng)用于指向該記錄符號(hào)表的指針獲得 2020/11/17 46 記錄的翻譯 T ? record D end T ? record L D end { := record(top(tblptr))。 struct node *next。 begin … a… … v… … exchange(i,j)… end。 function partition(y,z:integer):integer。end; procedure quicksort(m,n:integer)。a[i]:=a[j]。 begin … a… end; procedure exchange(i,j:integer)。 procedure readarray。 var a:array[0..10] of integer。 push(t,tblptr)。 enterproc(top(tblptr),t) } D?id:T {enter(top(tblptr),top(offset))。pop(tblptr)。 S {t := top(tblptr)。 D2 D ? proc id 。 push(t,tblptr)。 pop(tblptr)。 S ? 語(yǔ)義動(dòng)作用到的函數(shù) ? mktable(previous):創(chuàng)建一個(gè)新的符號(hào)表; ? enter(table, name, type, offset) ? addwidth(table, width):符號(hào)表的大?。? ? enterproc(table, name, newtable) 在 table指向的符號(hào)表中為 name建立一個(gè)新表項(xiàng); 2020/11/17 25 P ? prog id (input,output) M D。 S D ? D 。i:integer{(i,integer,8)。 :=4}{enter(i,offset)。offset:=8}。i:T {enter(,offset)。D ?x:real{(x,real,0)。D ?x:real{(x,real,0)。:=8} {enter(x,offset)。
點(diǎn)擊復(fù)制文檔內(nèi)容
教學(xué)課件相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1