Read-only flat-table TOML parser for fastC.
Part of the fastc-core launch set. Implementation ships in the
fastC v1.0 prelude — use toml::* works out of the box.
use toml::find_int; // (text, key, fallback) -> i64
use toml::find_bool; // (text, key, fallback) -> bool
Both lookups are scoped to the root table. Keys inside
[section] headers are skipped. Comments (# ...) are honored.
use toml::find_int;
use toml::find_bool;
let cfg: raw(u8) = cstr("\
# server config\n\
port = 8080\n\
debug = true\n\
\n\
[deploy]\n\
port = 9999 # section-scoped, NOT found by root lookup\n\
");
let port: i64 = find_int(cfg, cstr("port"), cast(i64, -1)); // 8080
let debug: bool = find_bool(cfg, cstr("debug"), false); // true
let absent: i64 = find_int(cfg, cstr("missing"), cast(i64, 42)); // 42
Arrays of tables, inline tables, dotted-key paths, date / time
values, multi-line strings, section-scoped lookups. The 80% case
is "pull a port / timeout / feature flag out of fastc.toml-shaped
config" — that's what v1 covers.
v0.1.0 — preview. API is final.
MIT