#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::Crafting Interpreters::Ch 17 Compiling Expressions
#columns:Front	Back	Tags
Crafting Interpreters ch 17, Compiling Expressions: what does it cover?	A single-pass compiler that parses expressions with a Pratt parser (a table of prefix and infix parse functions with precedence) and emits bytecode directly, with no AST.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::17 cracked.guide::kind::about
Crafting Interpreters ch 17, Compiling Expressions: why does it matter?	Pratt parsing is an elegant, compact way to handle operator precedence and is used in many real compilers and tools.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::17 cracked.guide::kind::why
Crafting Interpreters ch 17, Compiling Expressions: which part of the book is it in?	clox (bytecode VM, C)	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::17 cracked.guide::kind::part
Pratt parser: what is it?	A Pratt parser, or top-down operator precedence parser, parses expressions using a table that gives each token a prefix function, an infix function and a precedence.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::17 cracked.guide::kind::definition
Pratt parser: Is a Pratt parser recursive descent?	It is a top-down recursive parser too, but it drives precedence from a table instead of from a chain of grammar rules.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::17 cracked.guide::kind::definition
Pratt parser: What is binding power?	Another name for precedence in Pratt parsing: how strongly an operator holds on to the operands around it.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::17 cracked.guide::kind::definition
Crafting Interpreters ch 17: what traps should you watch for?	<ul><li>Getting precedence levels off by one in the rule table.</li><li>Forgetting that the compiler emits code as it parses, so order matters.</li></ul>	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::17 cracked.guide::kind::traps
Crafting Interpreters ch 17: which end-of-chapter challenges are worth your time?	Challenge 1 (trace a tricky expression through the parse functions) is the most important; do it on paper. Challenge 3 (add the ternary operator) is a good stretch. Do challenges that change Lox's behavior on a separate git branch. The cracked.guide check runs the official test suite for this chapter, and a challenge that changes semantics (new syntax, different errors) can make tests fail on main.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::17 cracked.guide::kind::challenges
Crafting Interpreters ch 17, Compiling Expressions: how should you work through it?	This chapter is dense. Read the Pratt parser part twice. Trace the parse of a small expression through parsePrecedence and the rule table by hand, which is exactly what challenge 1 asks.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::17 cracked.guide::kind::approach
