Skip to content

rumycoding/myFirstInterpreter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Crafting Interpreters Implementation

这是记录Crafting Interpreters 实现的repo。我很喜欢书里的这段话:

there is no magic at all. It's just code, and the people who hack on languages are just people.

虽然一直和代码编译器打交道,但在读这本书之前,编译器完全就是魔法!而读这本书就是,看魔法如何实现(?

我也很喜欢这篇Design Notes。即使没读过这本书也可以读读这篇note。可能那些最优秀的程序员都会有些奇怪(非贬义),会享受把脑子里奇怪的想法实现的过程。我可能还是缺乏一些去尝试奇怪想法的动力?

不过读这本书就能看到很多优雅的方法实现编译器的方法,比如:

  • Pratt Parser:用一个lookup table就可以实现语法树的单遍parse,但我很难说理解了它
  • Bound Method:Capture class的 this
  • UpValue: 用一个object就能实现Closure
  • Function Call Frame: 利用Call Frame实现Function的call和return
  • Interned String: 把string存在interned的hash table中,减少string compare的复杂度

尝试理解和实现这些方法都是很有趣的!

About

my coding exercise for interpreters

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published