A fork of https://github.com/munificent/craftinginterpreters with the code as it looks like at the end of each chapter.
Each directory contains the code as it looks at the end of each chapter.
See also https://craftinginterpreters.com/contents.html
Java chapters:
- 4. Scanning
- 5. Representing Code
- 6. Parsing Expressions
- 7. Evaluating Expressions
- 8. Statements and State
- 9. Control Flow
- 10. Functions
- 11. Resolving and Binding
- 12. Classes
- 13. Inheritance
C chapters:
- 14. Chunks of Bytecode
- 15. A Virtual Machine
- 16. Scanning on Demand
- 17. Compiling Expressions
- 18. Types of Values
- 19. Strings
- 20. Hash Tables
- 21. Global Variables
- 22. Local Variables
- 23. Jumping Back and Forth
- 24. Calls and Functions
- 25. Closures
- 26. Garbage Collection
- 27. Classes and Instances
- 28. Methods and Initializers
- 29. Superclasses
- 30. Optimization
I ran make split_chapters
(described in the original repo's README,
excerpted below) and added the result (the gen/
directory) to git.
You can also see what the interpreters look like at the end of each chapter. (I use this to make sure they are working even in the middle of the book.) This is driven by a script,
tool/bin/split_chapters.dart
that uses the same comment markers for the code snippets to determine which chunks of code are present in each chapter. It takes only the snippets that have been seen by the end of each chapter and produces a new copy of the source ingen/
, one directory for each chapter's code. (These are also an easier way to view the source code since they have all of the distracting marker comments stripped out.)
I also had to run make java_chapters
to run GenerateAst.java for each chapter
(GenerateAst creates the Expr.java and Stmt.java files).
I don't think there's a corresponding AST generator for the C chapters(?)
It looks like Expr.java and Stmt.java don't have marker comments stripped out, unfortunately!
If you're interested in Expr.java or Stmt.java, see also: https://craftinginterpreters.com/appendix-ii.html