Gary Knott 的Interpreting Lisp 非常好。
你也可以试试其他的,比如Jim Mayfield'sLisp。那里可能有很多小 Lisp...
您提到您不喜欢 C。也许您喜欢 Haskell——在这种情况下,您可以尝试 "Write yourself a Scheme in 48 hours",这是一个有趣的教程(您可以在 Haskell 中编写一个 Scheme 解释器)。
更新:我知道使用 Haskell 的 Lisper 几乎不会觉得舒服,但是嘿,它比 C 舒服得多(至少对我来说)!除此之外,HAskell 有一个很好的 FFI,所以使用 Haskell 制造的 Lisp 阅读器作为 C 兼容库应该很容易。
更新 2: 如果您想使用 XLisp,正如其他用户所建议的那样,您可能需要 src/xlread.c(863 行)和 include/xlisp.h(1379 行)- - 但我可能是错的......
更新 3: 如果您使用 Gary Knott 的 Lisp(一个 942 行的单个 C 文件),函数签名是 int32 sread(void)。如果我不需要任何花哨的东西(比如读取宏)或高度优化的东西(有一篇 PDF 论文描述了代码是如何实现的,所以你不必在迷宫中找到自己的方式),这将是我的选择。该函数的文档是:
This procedure scans an input string g using a lexical token scanning
routine, e(), where e() returns
1 if the token is '('
2 if the token is '''
3 if the token is '.'
4 if the token is ')' or a typed pointer d to an
atom or number stored in row ptrv(d) in the atom or number tables.
Due to the typecode (8 or 9) of d, d is a negative 32-bit integer. The
token found by e() is stripped from the front of g.
SREAD constructs an S-expression and returns a typed pointer to it as
its result.
看到 Gary 的 Lisp 已经过时,您需要对其进行更改以便编译。不包括 linuxenv.h,而是包括:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <setjmp.h>
另外,它在 64 位机器上也不起作用(sread 的文档应该会告诉你原因……)
更新 4:还有 Nils Holm 的 Scheme implementations(有描述内部结构的书籍)