Capstone projects

Three projects, built one lesson at a time, with nothing new in the language: every rule the course taught is used again and none is introduced. The first is a JSON parser in five lessons, from the tokenizer to the writer that round-trips a document and the test table that finds the bugs. The second is a task tracker in five: the model, a file format, the command line, the errors that reach the user as a message and a non-zero exit code, and the tests. The third is a search index in four, from the tokenizer to the inverted index, the ranked query and the benchmark that makes the hot path faster.

12.1 Capstone 1: a JSON tokenizer the project layout, the token type and a lexer that walks a JSON document (C++ 137) Open 12.2 Capstone 1: the parser a recursive descent parser, the value type it builds and the errors it reports (C++ 138) Open 12.3 Capstone 1: a JSON value an enum of object, array, string, number, bool and null, with accessors and printing (C++ 139) Open 12.4 Capstone 1: writing JSON escape strings, indent nested values and round-trip the document (C++ 140) Open 12.5 Capstone 1: testing the parser a table of good and bad documents, a test runner and the bugs it finds (C++ 141) Open 12.6 Capstone 2: a task model a task with an id, a state and a due date, and the operations that keep it valid (C++ 142) Open 12.7 Capstone 2: saving tasks a line-based file format, load and save, and a corrupt line that is skipped (C++ 143) Open 12.8 Capstone 2: the command line parse subcommands, dispatch to handlers and print a task list (C++ 144) Open 12.9 Capstone 2: error handling Result through the layers, error messages for the user and a non-zero exit code (C++ 145) Open 12.10 Capstone 2: testing the tracker test the model, the storage and the commands, with a temporary file per test (C++ 146) Open 12.11 Capstone 3: a tokenizer split documents into words, normalise case and keep the positions (C++ 147) Open 12.12 Capstone 3: the inverted index map a word to the documents and positions that hold it, and build it from a directory (C++ 148) Open 12.13 Capstone 3: queries and ranking AND and OR queries, a ranked answer and a phrase search over positions (C++ 149) Open 12.14 Capstone 3: measure and speed it up time the index build and the queries, then improve the hot path and measure again (C++ 150) Open

Lessons