90分钟实现一门编程语言(极简解释器教程)

2019-12-30 14:54:22王冬梅

设计实现方面:

    使用了可变(Mutable)类型。 没有任何注释(因为觉得没有必要 -_-)。 糟糕的类型系统:Lisp类语言中的数据和程序可以不分彼此,而iScheme的实现中确把数据和程序分成了 SObject 和 SExpression ,现在我依然没有找到一个融合他们的好办法。

这些就留到以后慢慢处理了 -_-(TODO YOUR ASS)

延伸阅读
书籍

    Compilers: Priciples, Techniques and Tools Principles: http://www.easck.com/Compilers-Principles-Techniques-V-Aho/dp/1292024348/ Language Implementation Patterns: http://www.easck.com/Language-Implementation-Patterns-Domain-Specific-Programming/dp/193435645X/ *The Definitive ANTLR4 Reference: http://www.easck.com/Definitive-ANTLR-4-Reference/dp/1934356999/ Engineering a compiler: http://www.easck.com/Engineering-Compiler-Keith-Cooper/dp/012088478X/ Flex & Bison: http://www.easck.com/flex-bison-John-Levine/dp/0596155972/ *Writing Compilers and Interpreters: http://www.easck.com/Writing-Compilers-Interpreters-Software-Engineering/dp/0470177071/ Elements of Programming: http://www.easck.com/Elements-Programming-Alexander-Stepanov/dp/032163537X/

注:带*号的没有中译本。

文章

大多和编译前端相关,自己没时间也没能力研究后端。-_-

为什么编译技术很重要?看看 Steve Yegge(没错,就是被王垠黑过的 Google 高级技术工程师)是怎么说的(需要翻墙)。

http://www.easck.com/2007/06/rich-programmer-food.html

本文重点参考的 Peter Norvig 的两篇文章:

    How to write a lisp interpreter in Python: http://www.easck.com//norvig.com/lispy2.html

几种简单实用的语法分析技术:

    LL(k) Parsing: http://www.easck.com/2008/09/26/recursive-descent-ll-and-predictive-parsers/ http://www.easck.com/2009/03/20/a-recursive-descent-parser-with-an-infix-expression-evaluator/ http://www.easck.com/2009/03/14/some-problems-of-recursive-descent-parsers/ Top Down Operator Precendence:http://www.easck.com/tdop/tdop.html Precendence Climbing Parsing:http://www.easck.com/wiki/Operator-precedence_parser

 

 
注:相关教程知识阅读请移步到c#教程频道。