Skip to content

yhslai/haxetoml

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 

Haxetoml

A Haxe implementation of TOML v0.1.0 language.

Install

haxelib install haxetoml

Usage

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');

Manually Test

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

To-Do

  • Set default value
  • Compile-time parsing with marco
  • Stringify

About

A TOML language implementation in Haxe

Resources

License

Stars

Watchers

Forks

Packages

No packages published