Tutorial: TOML Parser
Build a complete TOML parser with round-trip printing using synkit.
Source Code
📦 Complete source: examples/toml-parser
What You’ll Build
A parser for a TOML subset supporting:
# Comment
key = "value"
number = 42
flag = true
[section]
nested = "data"
[section.subsection]
array = [1, 2, 3]
inline = { a = 1, b = 2 }
Source Code
The complete example lives in examples/toml-parser/. Each chapter references the actual code.
Chapters
- Project Setup - Dependencies, error type,
parser_kit!invocation - Defining Tokens - Token patterns and attributes
- AST Design - Node types with
Spanned<T> - Parse Implementations - Converting tokens to AST
- Round-trip Printing -
ToTokensfor output - Visitors - Traversing the AST
- Testing - Parse and round-trip tests