small & readable scheme interpreter in C++?

喜欢而已 提交于 2019-12-03 06:30:45

问题


Anyone know of a good / small scheme interpreter in C++? Perferably something < 2000 LOC, with a simple garbage collectro (either compacting or mark & sweep), no need to support all of R5RS, just basics of if/lambda/set!/cons/car/cdr and some basic operations.

Thanks!


回答1:


Well, there's a veeery tiny lisp by Gary Knott. Not even close to R5RS, but it's small, and comes with a book describing the internals! However, it's C, not C++, and as far as I can remember there's no GC (but I could be wrong).

There's also Mini Scheme by Nils Holm, but it's also C, and a bit larger than what you asked (2404 lines of C plus 1352 of Scheme). Nils has also written Scheme 9 from Empty Space, which is larger but also comes with a book describing every piece of code.

Tinyscheme is another small Scheme (4500 lines of C plus 452 of Lisp)...




回答2:


Here's a long list of scheme implementations:

http://community.schemewiki.org/?scheme-faq-standards#implementations

Several of them are embeddable interpreters, mostly in C. That shouldn't be a deal breaker for C++.




回答3:


Unfortunately Scheme Implementations doesn't organize based on such practical criteria. :)

I did find one Scheme Interpreter in C++ that you might check out to see if it fits your needs. I haven't tried this particular one, so this isn't an endorsement.




回答4:


There's also Gambit Scheme. It's also written in C and has the advantage that it's designed to be embeddable. I have personally used it to embed Scheme inside Excel 2003!

Although it's very much work in progress it works fine and you could easily adapt it to whatever C++ needs you have.




回答5:


I have started a project at my university to do exactly this. Shaka Scheme is an attempt to implement R7RS in C++.

We are working towards implementing macros and continuations as of the time of writing, and will focus on an implementation model after R. Kent Dybvig's dissertation's heap-allocated model for evaluation.

In the future, we hope to have a fully-comprehensible documentation database through the GitHub wiki of our design and methodology to make implementation of Scheme readable to novices.



来源:https://stackoverflow.com/questions/2610716/small-readable-scheme-interpreter-in-c

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!