toml.parser
import toml.parser
tomldoes not re-export this module, so it is reached only by importing it directly.
Reading TOML text into the document tree, losing nothing.
The parser is a single pass over the characters. It builds the nodes in
document.zu, and every byte it consumes ends up in one of them: a
value’s text in its raw, the spaces around an = in the pair that
holds it, a comment in the prefix of whatever it sits above. Nothing is
normalised on the way in, so nothing has to be reconstructed on the way
out.
Alongside the tree it keeps a second, smaller structure recording what has been declared. TOML’s rules about redefinition are not about text at all: a table may be created implicitly by a header below it, created by a dotted key, or written out in full, and which of those happened decides whether the next header naming it is legal. Keeping that separate from the format tree is what keeps both readable.
Functions
parse()
toml.parser.parse(text: string) -> Document
Reads TOML text and returns the document tree it describes.
Every byte of the input ends up somewhere in the tree, so rendering the result without editing it reproduces the input exactly.
Parameters
text(string)
Returns Document
Raises ParseError On any syntax or structural error, with the line
and column it stopped at.
2026, Richard Ore and The Zuri Contributors