A Haxe implementation of TOML v0.1.0 language.
haxelib install haxetoml
Given foo.toml
:
[foo]
a = 1
[foo.bar]
b = ["2", "3"]
You can parse it with:
import sys.io.File;
var toml = File.getContent('foo.toml');
var parser = new haxetoml.TomlParser();
var parsed = parser.parse(toml);
parsed.foo; // => 1
parsed.foo.bar[1]; // => "3"
There are also some shortcut methods:
var fileContent = File.getContent('foo.toml');
var parsed = haxetoml.TomlParser.parseString(fileContent);
// or this shortcut, available on neko, cpp and php:
var parsed = haxetoml.TomlParser.parseFile('foo.toml');
Compile the test program first:
$ haxe cli_test.hxml
Run it:
# You can replace 'simple' with 'harder', 'empty' or whatever file name in resources/test_files
# C++
cli_test/bin/cpp/ParserTest simple
# Neko
neko cli_test/bin/ParserTest.n simple
- Set default value
- Compile-time parsing with marco
- Stringify