• Stars
    star
    126
  • Rank 284,543 (Top 6 %)
  • Language
    C
  • License
    BSD 3-Clause "New...
  • Created almost 12 years ago
  • Updated over 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

libtoml

Fast C parser using Ragel to generate the state machine.

Currently targetted at TOML v0.4.0

Usage

#include <toml.h>

struct toml_node *root;
struct toml_node *node;
char *buf = "[foo]\nbar = 1\n";
char *value;

toml_init(&root);
toml_parse(root, buf, len);

node = toml_get(root, "foo.bar");

toml_dump(root, stdout);

value = toml_value_as_string(node);
free(value);

toml_free(root);

Building it

Building libtoml requires cmake, ragel (the parser generator) and libicu for unicode support.

> cmake -G "Unix Makefiles" .
> make

Testing it

Compatible with toml-test when invoked as 'parser_test'

> ln -s main parser_test
> $GOPATH/bin/toml-test $PWD/parser_test

TODO

More tests