A flat list of pairs is not enough for real config; you need grouping. Today you parse a table header, a name in square brackets, which starts a new subtable that following pairs belong to.
Parse a [name] header so that following pairs go into that subtable.
Configuration is naturally grouped - server settings here, database settings there
[server]. Everything after that header, up to the next header
or the end of the file, belongs to that table. So [server] followed by port = 80
puts port inside server, not at the top level.The mechanism is a current-table pointer. It starts at the root, and every key/value pair is appended to whatever table it currently points at. A header does one thing: create the named subtable under the root and move the pointer to it. Pairs written before any header stay at the root, since that is where the pointer begins. This single piece of state - “which table are we filling?” - is what turns a flat parser into one that builds a shallow tree, and the next lessons deepen it with dotted names.
// keep a `current *Table` pointer, starting at the root// a line matching [ key ] is a table header:// make a new child Table under the root at that key// set current = that child// a key/value pair is appended to `current`, not always the root