#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::Crafting Interpreters::Ch 06 Parsing Expressions
#columns:Front	Back	Tags
Crafting Interpreters ch 6, Parsing Expressions: what does it cover?	A recursive descent parser for Lox expressions, with precedence and associativity encoded in the grammar, plus syntax error reporting and panic-mode recovery by synchronizing at statement boundaries.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::06 cracked.guide::kind::about
Crafting Interpreters ch 6, Parsing Expressions: why does it matter?	Recursive descent is how most production compilers (GCC, Clang, V8, Roslyn) parse. Once you can write one, you can parse almost anything.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::06 cracked.guide::kind::why
Crafting Interpreters ch 6, Parsing Expressions: which part of the book is it in?	jlox (tree-walk interpreter, Java)	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::06 cracked.guide::kind::part
Recursive descent parser: what is it?	A recursive descent parser is a top-down parser in which each grammar rule becomes a function, and functions call each other to match nested structure.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::06 cracked.guide::kind::definition
Recursive descent parser: Why not use a parser generator?	You can, but a hand-written recursive descent parser is easy to read, gives better error messages and needs no extra tool. Many large compilers use one.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::06 cracked.guide::kind::definition
Recursive descent parser: Can recursive descent handle left recursion?	Not directly; a rule like expr -&gt; expr + term loops forever. You rewrite it as a loop, which is what the Lox grammar does.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::06 cracked.guide::kind::definition
Crafting Interpreters ch 6: what traps should you watch for?	<ul><li>Getting associativity wrong by using recursion where the book uses a loop.</li><li>Error recovery that never resynchronizes, causing a cascade of bogus errors.</li></ul>	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::06 cracked.guide::kind::traps
Crafting Interpreters ch 6: which end-of-chapter challenges are worth your time?	Challenges 1 (comma operator) and 2 (the ternary ?: operator) are great practice at adding grammar rules with the right precedence. Challenge 3 (error productions for binary operators missing a left operand) teaches good error messages. 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::06 cracked.guide::kind::challenges
Crafting Interpreters ch 6, Parsing Expressions: how should you work through it?	Map each grammar rule to its parsing method and check them side by side. Trace the parse of an expression like 1 - 2 * 3 == 4 on paper through the call stack.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::06 cracked.guide::kind::approach
