Giter VIP home page Giter VIP logo

zig-toml's Introduction

Build Status

zig-toml

A TOML parser written in Zig targeting TOML v0.5.0. The end goal is for the program to be robust, with no crashing given any situation. Though, in its current state this program is probably far from that goal.

There is currently a lack of documentation but the tests contained should give enough of an idea on how to use this.

Quickstart Guide

Zig Version Support

This table shows the project's current compatibility status with zig:

Zig Version Status
0.11.0 โœ… Supported
0.10.1 and below โŒ Not Supported

Features

  • Tables
  • Keys (all kinds)
  • Single-line strings
  • Integers
  • Booleans
  • Arrays
  • Comments
  • Floats
  • Hexadecimal, octal, and binary numbers
  • Multi-line strings
  • String escapes
  • Inline tables
  • Array of tables
  • Time and date

Building and Usage

This library is self-contained and requires no dependencies.

To build simply run zig build and that will output a file called libtoml.a that you can link with your program.

If you want to run the tests then use the zig build test command.

zig-toml's People

Contributors

aeronavery avatar buzzwordchief avatar chiumichael avatar craigfay avatar dgbuckley avatar joachimschmidt557 avatar justjosias avatar nitinprakash96 avatar paoda avatar stef avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

zig-toml's Issues

Bug: Parser panics and fails when parsing floats

This code panics

test "float" {
    var parser = try parseContents(std.testing.allocator,
        \\ foo=1.234
    );
    defer parser.deinit();

    var table = try parser.parse();
    defer table.deinit();

It seems to be related to the placement of the decimal

This code does not panic

test "float" {
    var parser = try parseContents(std.testing.allocator,
        \\ foo=12.34
    );
    defer parser.deinit();

    var table = try parser.parse();
    defer table.deinit();

@aeronavery

`parseFile` leaks memory

Given the test case:

test "memory cleanup" {
    var table = try parseFile(std.testing.allocator, "test/basic.toml", null);
    defer table.deinit();
}

note that zig build test outputs:

Test [40/40] test.memory cleanup... [gpa] (err): memory address 0x7fb15b146000 leaked: 
/opt/zigup/zig/0.11.0-dev.64+e9a12491f/files/lib/std/array_list.zig:295:72: 0x222003 in shrinkAndFree (test)
                self.items = self.allocator.realloc(self.allocatedSlice(), new_len) catch |e| switch (e) {
                                                                       ^
/opt/zigup/zig/0.11.0-dev.64+e9a12491f/files/lib/std/io/reader.zig:78:45: 0x221954 in readAllArrayListAligned__anon_4289 (test)
                    array_list.shrinkAndFree(start_index);
                                            ^
/opt/zigup/zig/0.11.0-dev.64+e9a12491f/files/lib/std/fs/file.zig:951:46: 0x22141a in readToEndAllocOptions__anon_4139 (test)
        self.reader().readAllArrayListAligned(alignment, &array_list, max_bytes) catch |err| switch (err) {
                                             ^
/opt/zigup/zig/0.11.0-dev.64+e9a12491f/files/lib/std/fs.zig:2076:42: 0x220df4 in readFileAllocOptions__anon_3957 (test)
        return file.readToEndAllocOptions(allocator, max_bytes, stat_size, alignment, optional_sentinel);
                                         ^
/opt/zigup/zig/0.11.0-dev.64+e9a12491f/files/lib/std/fs.zig:2051:41: 0x220af6 in readFileAlloc (test)
        return self.readFileAllocOptions(allocator, file_path, max_bytes, null, @alignOf(u8), null);
                                        ^
/home/paoda/dev/open/zig-toml/src/toml.zig:329:91: 0x2228d0 in initWithFile (test)
        var contents = try std.fs.cwd().readFileAlloc(allocator, filename, std.math.maxInt(usize));
                                                                                          ^
/home/paoda/dev/open/zig-toml/src/toml.zig:800:41: 0x22380f in parseFile (test)
    var parser = try Parser.initWithFile(allocator, filename);
                                        ^
/home/paoda/dev/open/zig-toml/src/toml.zig:1402:30: 0x22918d in test.memory cleanup (test)
    var table = try parseFile(std.testing.allocator, "test/basic.toml", null);
                             ^

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.