class
TOML::Parser
- TOML::Parser
- Reference
- Object
Overview
Parses a TOML v1.0 document into a Document AST.
The parser is a thin layer over Lexer: it consumes the token
stream, builds AST nodes, and decodes value text through
ValueDecoder. Trivia tokens (Whitespace, Newline,
Comment) are not skipped — they are folded into the
surrounding node's raw_* fields so that Document#to_toml
produces byte-identical output for unmodified documents.
Scope of the current MVP
Implemented:
- Top-level
key = valuelines [a.b.c]standard table headers[[a.b]]array-of-tables headers- Bare keys, quoted keys (basic and literal), dotted keys
- Values: strings (basic, multi-line basic, literal,
multi-line literal), integers (decimal, hex, octal, binary,
with optional sign and
_digit separators), floats (includinginfandnan), booleans - Standalone comment lines and blank lines
Not yet implemented (planned for the next iteration):
- Datetimes (RFC 3339 offset, local datetime, local date, local time)
- Arrays
[1, 2, 3] - Inline tables
{ key = "val" } - Validation that the same key is not redefined and that an already-defined inline table is not extended later