#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::Crafting Interpreters::Ch 05 Representing Code
#columns:Front	Back	Tags
Crafting Interpreters ch 5, Representing Code: what does it cover?	You design the syntax tree for expressions: context-free grammars, the expression grammar for Lox, a small Java program that generates the AST classes, and the Visitor pattern for operating on trees, ending with an AST pretty printer.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::05 cracked.guide::kind::about
Crafting Interpreters ch 5, Representing Code: why does it matter?	ASTs are the central data structure of every compiler, linter and code formatter. The Visitor pattern explanation here is one of the clearest anywhere.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::05 cracked.guide::kind::why
Crafting Interpreters ch 5, Representing Code: which part of the book is it in?	jlox (tree-walk interpreter, Java)	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::05 cracked.guide::kind::part
Crafting Interpreters ch 5, a common trap: “In other languages, a sum type plus pattern matching (Rust enums, TypeScript unions) can replace the Visitor pattern.” What's the catch?	That is fine, but understand what the Visitor is doing first.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::05 cracked.guide::kind::trap
Crafting Interpreters ch 5: what traps should you watch for?	<ul><li>Forgetting to rerun GenerateAst after changing the grammar, then wondering why classes are missing.</li></ul>	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::05 cracked.guide::kind::traps
Crafting Interpreters ch 5: which end-of-chapter challenges are worth your time?	Challenge 3 (an RPN printer) is short and a nice check that you understand visitors. Challenges 1 and 2 are thought exercises about grammars and functional versus object-oriented style.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::05 cracked.guide::kind::challenges
Crafting Interpreters ch 5, Representing Code: how should you work through it?	Write the GenerateAst tool exactly as shown; it saves a lot of typing later. Spend real time on the section about the expression problem and the Visitor pattern until you can explain why it exists.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::05 cracked.guide::kind::approach
