三地址代码是编译原理语法分析后的中间语言的一种,这是我刚完成的三地址代码生成器,符合的语法规则及其语义规则如下(S→if C then S1 else S2,这条规则没有加,其余都已完成,也许还有bug,欢迎大家给予指正):产生式 语义规则S → id = E S.code = E.code || gen(id.place’:=’E.place)S → if C then S1 C.true = newlabel; C.false = S.next;S1.next = S.next;S.cod
Swiftz 是一个 Swift 库,实现了函数式编程。
示例代码:
let xs = [1, 2, 0, 3, 4]
// we can use the Min semigroup to find the minimal element in xs
sconcat(Min(), 2, xs) // 0
// we can use the Sum monoid to find the sum of xs
mconcat(Sum(i: { return nint8 }), xs) // 10