I'd like to try to create a document structure and table of contents in pure TeX. Does anyone know of any resources or examples to do this? My purpose is mainly educational, to learn how to write macros and structure documents in pure TeX.
I know how to define basic commands using \def, and I've written documents in plain TeX but I don't understand enough about programming in TeX to feel able to tackle a big task like this.

eplain.tex– egreg Jul 02 '16 at 23:20plainformat already being defined, but the bits about the primitives and the defining of that format etc.) But this is presumably obvious. – cfr Jul 03 '16 at 00:30