我正试图通过Abdulaziz Ghuloum的Compilers: Backend to Frontend (and Back to Front Again)努力。它似乎缩写为完整课程/研讨会中的预期,所以我试图自己填写这些内容。
例如,我尝试在DrScheme的R5RS风格中使用他的测试框架,但它似乎不喜欢宏的东西:
src/ghuloum/tests/tests-driver.scm:6:4: read: illegal use of open square bracket
我已经阅读了他关于课程的介绍文件An Incremental Approach to Compiler Construction,其中对所使用的技术进行了很好的概述,并提到了几个可能需要为“额外信用”实现的功能的方案,但是他没有提到他在课程中使用的计划。
更新
我还在深入研究原始问题(调查Eli建议的Petit Scheme等选项),但发现了一个与Gholoum工作有关的有趣链接,所以我将其包括在内。
[Ikarus Scheme](http://en.wikipedia.org/wiki/Ikarus_(Scheme_implementation))是Ghuloum思想的实际实现,似乎是他博士论文的一部分。它应该是R6RS的首批实现之一。我是现在尝试安装Ikarus,但配置脚本不想识别我的系统安装的 libgmp.so ,所以我的问题仍未解决。
示例
以下示例似乎适用于使用Pretty Big
在DrEd中运行的PLT 2.4.2(require lang/plt-pretty-big)
(load "/Users/donaldwakefield/ghuloum/tests/tests-driver.scm")
(load "/Users/donaldwakefield/ghuloum/tests/tests-1.1-req.scm")
(define (emit-program x)
(unless (integer? x) (error "---"))
(emit " .text")
(emit " .globl scheme_entry")
(emit " .type scheme_entry, @function")
(emit "scheme_entry:")
(emit " movl $~s, %eax" x)
(emit " ret")
)
尝试用 #lang scheme 替换 require 指令会导致错误消息
foo.scm:7:3: expand: unbound identifier in module in: emit
似乎是由于无法加载 tests-driver.scm 。尝试使用 #lang r6rs 会禁用REPL,我真的很想使用它,所以我将尝试继续使用Pretty Big。
感谢Eli Barzilay的耐心帮助。