TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: A (barely usable) Scheme Interpreter in C

4 点作者 tectonicfury超过 3 年前

1 comment

tectonicfury超过 3 年前
I implemented a subset of Scheme, one that might just get you past the first chapter of SICP, in C. I wanted to implement a Scheme interpreter in C after doing SICP to attain a sense of closure and to be sure that I really got the bare essentials of programming languages and program evaluation. So here it is for anyone wanting to try it out. Do read the README on GitHub[1] for what I have made and to understand its limitations.<p>It wasn&#x27;t easy for me as a non CS person (I am a Chemical Engineer). I started out reading theory heavy books like Torczon and Cooper but feeling intimidated by the math involved in finite automaton style scanner generators, I switched to Bob Nystrom&#x27;s Crafting Interpreters [2] and his book made the scanning part smooth and intuitive. Next I tried to study parsing from his book but didn&#x27;t find parsing to be as enjoyable. I then went to the dragon book , which I had found to be very dense the first time I flipped through it an year ago. This time I found it to be much more approachable, thanks again to what I had read in Nystrom&#x27;s book. Precedence and associativity made more sense when I read it a second time. But it turns out that Scheme&#x27;s grammar is really simple: Expr -&gt; atom | &#x27;(&#x27; Expr &#x27;)&#x27;, so I stopped reading and started coding.<p>It&#x27;s barely usable because it has no GC, and I may have to rewrite it from scratch for implementing one. In the meantime I am thinking of doing a rewrite in Java, and then do part 3 from Crafting Interpreters, where the author implements everything in C.<p>Still very much a newbie, I welcome criticisms and directions for moving it forward.<p>[1] <a href="https:&#x2F;&#x2F;github.com&#x2F;TectonicFury&#x2F;CSCMIC" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;TectonicFury&#x2F;CSCMIC</a><p>[2] <a href="https:&#x2F;&#x2F;craftinginterpreters.com" rel="nofollow">https:&#x2F;&#x2F;craftinginterpreters.com</a>