contributed by <Yuessiah
>
as.c
:#define
使用 do { ... }while(0)
是為了讓使用此 macro 行為像 function 用法[1], 不過我覺得若 macro 只有一行指令時這樣用法是顯得有點冗。
function make_oprend
及 make_result
中多處在 exit(-1)
之前執行 free(line)
, 這是不需要的[2]。
而且 clang-format 會在 function assemble_line
中報 (error) Deallocating a deallocated pointer: line_backup
先將整份文件讀一遍,有出現 label 的地方將行數及 label 字串紀錄到一份表中
接著繼續照先前作法,但當 operand 遇到 label 字串,就從表中將對應的行數賦值給 operand。
詳細看 code。
此實做會印出 f(n=6), n 必須大於等於 1