I am trying to parse a SQLite BTree Page (https://www.sqlite.org/fileformat2.html#btree) with nom.
Nom works fine for parsing both headers (the database file header and the btree header), as well as the cell pointer array. I am now stuck on how to parse the individual cells.
As I understand it, nom just traverses linearly through the input, but what I rather need is random access: Take a value from the cell pointer array, jump to that location in the page and then parse it.
Is this a valid approach? Should I just wrap the remaining input after the header in a cursor and randomly access the cell pointer locations?
Another idea I had was to order the cell pointer array in ascending order and only take as much bytes until the next cell starts. The problem here is that each cell's payload length varint contains the overflow. I am having problem on how to identify the exact length of the cell payload on that page, because a free block can follow a cell. For that, I would need to first parse the linked list of all free-block pages in order to retrieve the locations and length of all free blocks, before I can start parsing the cell blocks. But then I'm back at random access.