Crafting interpreters

Chapter 1

  • You can implement a compiler in any language, including the same language it compiles, a process called ā€œself-hostingā€.

  • You can’t compile it using itself yet, but if you have another compiler for your language written in some other language, you use that one to compile your compiler once.

    • Now you can use the compiled version of your own compiler to compile future versions of itself and you can discard the original one compiled from the other compiler.

    • This is called ā€œbootstrappingā€ from the image of pulling yourself up by your own bootstraps.

  • A parser takes the flat sequence of tokens and builds a tree structure that mirrors the nested nature of the grammar.

    • These trees have a couple of different namesā€Šā€”ā€Šā€œparse treeā€ or ā€œabstract syntax treeā€ā€Šā€”ā€Šdepending on how close to the bare syntactic structure of the source language they are.

      • In practice, language hackers usually call them ā€œsyntax treesā€, ā€œASTsā€, or often just ā€œtreesā€.

Last updated