Capstone 1, a JSON reader and writer
The first project is a JSON reader and writer built from nothing: a tokenizer, a recursive descent parser, a value type, and a writer that prints the document back. Errors carry a line and a column, table tests and a fuzz target guard the parser, and a command line tool puts it in a shell. The part ends with a benchmark against encoding/json.
113
Capstone 1: a JSON tokenizer
the project layout, the token type and a lexer that walks a JSON document
Open
114
Capstone 1: the parser
a recursive descent parser, the value type it builds and the errors it reports
Open
115
Capstone 1: the value type
an object, an array, a string, a number, a bool and null, with accessors and printing
Open
116
Capstone 1: the writer
escape strings, indent nested values and round-trip the document
Open
117
Capstone 1: errors with positions
a line and a column in the error, the offset carried through the parser and a message a user can act on
Open
118
Capstone 1: table tests and fuzzing
a table of good and bad documents, a fuzz target and the bug it finds
Open
119
Capstone 1: the command line tool
a flag, a file argument, the exit codes and the output format
Open
120
Capstone 1: benchmarks against encoding/json
a benchmark of both parsers, -benchmem and what the standard library does better
Open