#separator:tab
#html:true
#notetype:Basic
#tags column:3
#deck:cracked.guide::Crafting Interpreters::Ch 04 Scanning
#columns:Front	Back	Tags
Crafting Interpreters ch 4, Scanning: what does it cover?	You build the scanner for jlox: turning source text into a list of tokens, handling lexemes, literals, keywords and identifiers, line numbers for errors, and the first bits of error reporting.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::04 cracked.guide::kind::about
Crafting Interpreters ch 4, Scanning: why does it matter?	Every tool that reads text (config parsers, linters, syntax highlighters) starts with a scanner. It is the cleanest first step into the codebase.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::04 cracked.guide::kind::why
Crafting Interpreters ch 4, Scanning: which part of the book is it in?	jlox (tree-walk interpreter, Java)	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::04 cracked.guide::kind::part
jlox: what is it?	jlox is the tree-walk interpreter for the Lox language, written in Java in chapters 4 to 13 of Crafting Interpreters.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::04 cracked.guide::kind::definition
jlox: Can I write jlox in another language?	Yes, many people do, but you have to translate the book's Java as you go. The test suite still works: point it at your executable.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::04 cracked.guide::kind::definition
jlox: Does jlox need a specific Java version?	No recent feature is required. Any current JDK works; the book's code is plain Java.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::04 cracked.guide::kind::definition
Crafting Interpreters ch 4, a common trap: “Writing jlox in a language other than Java: totally fine, but you translate every snippet yourself and the Visitor-heavy code in later chapters is more work in some languages.” What's the catch?	Check the wiki of other implementations for your language.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::04 cracked.guide::kind::trap
Crafting Interpreters ch 4, a common trap: “Using a Java version too old for the code.” What's the catch?	Any modern JDK (17 or 21) works.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::04 cracked.guide::kind::trap
Crafting Interpreters ch 4: what traps should you watch for?	<ul><li>Off-by-one errors in current/start indices when extracting lexemes.</li><li>Forgetting to increment the line counter inside multi-line strings.</li></ul>	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::04 cracked.guide::kind::traps
Crafting Interpreters ch 4: which end-of-chapter challenges are worth your time?	Challenge 4 (C-style block comments) is the one to actually implement; consider supporting nesting as the challenge suggests. Challenges 1 to 3 are discussion questions; think about them briefly. 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::04 cracked.guide::kind::challenges
Crafting Interpreters ch 4, Scanning: how should you work through it?	Type the code yourself instead of copying; that is the whole point of the book. Run it on small inputs after each step. Set up the official test runner this week so every later chapter is checked automatically.	cracked.guide cracked.guide::phase::interpreters cracked.guide::chapter::04 cracked.guide::kind::approach
