/libtoml2

TOML parser in C that passes all of the burntsushi test suite.

Primary LanguageCOtherNOASSERTION

libtoml2

Because libtoml is a wreck and I have more time than wit.

libtoml2 is a toml 0.4.0 parser in C that passes all of the burntsushi test suite. It should be noted that the burntsushi test suite is for toml 0.2.0. AFAIK the differences between 0.2.0 and 0.4.0 are non-structural and only add further restrictions (which I beleaf are handled).

Building

Dependencies:

  • POSIX system with tree.h.
  • libicuuc since TOML is UTF-8 encoded.
  • libcheck for the test suite.
./build.sh

This should produce three binaries, ./bin/libtoml2.a, ./bin/libtoml2.test, and ./bin/burntsushi:

  • libtoml2.a is the final artifact that can be statically linked or whatever.
  • libtoml2.test is the libcheck binary that runs the built-in test suite.
  • burntsushi is the binary compatible with the burntsushi test harness.

libtoml2.test is automatically invoked by build.sh. For development, it should also be run through valgrind to ensure that nothing horrible happens.

Usage

Statically link in libtoml2.a and #include "toml2.h". The other headers are for internal use. Refer to toml2.h for documentation; in general accessors are considered a stable API. Struct internals may change.

Issues

  • No build system is used. Is this an issue? I don't know. I don't mind cmake/autotools but I'm not going to bother hooking them up.
  • Build system only emits static libraries. Dynamic linking is for X11. If you need it, feel free to submit a PR.
  • It is not yet tested to behave correctly when malloc fails.
  • Parsing of doubles is woefully sub-optimal.
  • Spaces between [/] in [[array-of-tables]] do not emit an error.
  • Error reporting is currently very poor.
  • Grammar is poorly expressed. Whoops.
  • Codebase may contain snark.
  • Probably some untested edge-cases. This isn't exactly battle-hardened code.