ccccourse / sp108b

系統程式 -- 108 下學期 (陳鍾誠課程的作業)
0 stars 32 forks source link

習題: 請為以下編譯器加上 IF 的語法,並撰寫測試範例測試之! #3

Open ccckmit opened 4 years ago

ccckmit commented 4 years ago

https://github.com/ccccourse/sp/tree/master/code/c/02-compiler/03-compiler

寫完請放入你 fork 的 sp108b 專案,就算繳交完成!

參考語法

IF = if (E) STMT (else STMT)? STMT = IF | WHILE | BLOCK | ASSIGN

(必須要附上測試範例與執行方法 -- 用 README.md 描述之)

測試範例

a = 3;
b = 5;
if (a > b)
    t = a;
else
   t = b;

更多資訊請看討論

https://www.facebook.com/groups/ccccourse/permalink/289295752040743/

鍾瑄 老師請問撰寫測試範例指的是要自己寫一個程式嗎?
陳鍾誠 用原本 03-compiler 修改就行了
陳鍾誠 當然想要重寫一個也可以 (不過這比較難)
陳鍾誠 測試範例像這樣:
a = 3;
b = 5;
if (a > b)
t = a;
else
t = b;
陳鍾誠
陳鍾誠 你的程式必須要能產生對應的中間碼!

韓茉茉 老師請問什麼是對應的中間碼?

陳鍾誠 像 sum.c
s=0;
i=1;
while (i < 11) {
s = s + i;
i = i + 1;
}
就被轉成
t0 = 0
s = t0
t1 = 1
i = t1
(L0)
t2 = i
t3 = 11
t4 = t2 < t3
if not T4 goto L1
t5 = s
t6 = i
t7 = t5 + t6
s = t7
t8 = i
t9 = 1
t10 = t8 + t9
i = t10
goto L0
(L1)
這就是中間碼!
ArthurLiao0816 commented 4 years ago

110710529 廖明志->https://github.com/ArthurLiao0816/sp108b

ayd0122344 commented 4 years ago

資工二 110710507 徐熙堯

Yongsin0 commented 4 years ago

110710544 陳詠鑫 -> https://github.com/Yongsin0/sp108b/blob/master/README.md

syuan0327 commented 4 years ago

資工二110710520 鍾瑄 https://github.com/syuan0327/sp108b/tree/master/03-compiler

AndrewDTN commented 4 years ago

https://github.com/AndrewDTN/sp108b/tree/master/homework/compiler-if 資工二110710539 張仲恩

JesusDick commented 4 years ago

https://github.com/JesusDick/sp108b/tree/master/HomeWork/03-compiler 資工二110710546 廖振鈞

ja1223 commented 4 years ago

資工二 110710521 吳婕安 https://github.com/ja1223/sp108b/tree/master/HW/03compiler%2Bif

fairy042026 commented 4 years ago

資工二 110710519 張瀞云 https://github.com/fairy042026/sp108b/blob/master/hw/03-compiler

weng0418 commented 4 years ago

資工二110710547翁瑋泓 https://github.com/weng0418/sp108b/blob/master/README.md

hongyushi101094 commented 4 years ago

資工二 110710533施泓宇 https://github.com/hongyushi101094/sp108b/tree/master/homework/compiler-if

ChangYuTeng commented 4 years ago

資工二 110710501張育騰 https://github.com/TiaoTiao87/sp108b/tree/master/03-compiler

kevin823lin commented 4 years ago

資工二 110710528 林子豪 https://github.com/kevin823lin/sp108b/tree/master/HW-03-compiler

rightmilk commented 4 years ago

資工二 110710514 施侑儒 https://github.com/rightmilk/sp108b/tree/master/03-compiler

asd153866714 commented 4 years ago

資工二 110713305 黃朝新 https://github.com/asd153866714/sp108b/tree/master/homework/03-compiler

KMC1911 commented 4 years ago

資工二 110710545 陳楷茗 https://github.com/mailk8811/sp108b/tree/master/HOMEWORK/03-compiler

tyiio445 commented 4 years ago

資工二110710527 王博緯 https://github.com/sleepy9487/sp108b

xiaotsai commented 4 years ago

資工二 110710551 蔡宗樺 https://github.com/xiaotsai/sp108b/tree/master/homework/03-compiler

zixxizxx commented 4 years ago

資工二 110710540 劉瑞姿 https://github.com/zixxizxx/sp108b/tree/master/c/02-compiler/03-compiler