~cricket/zckt

ac62d8668eb9c1620606a13e0dfd176825f2c8b9 — c piapiac 23 days ago 5d2331a
fix comments eating up after newline
1 files changed, 5 insertions(+), 6 deletions(-)

M zckt.zig
M zckt.zig => zckt.zig +5 -6
@@ 1,6 1,4 @@
// small, bodged together ckt parser
//
//
const std = @import("std");
const debug = std.debug;
const fmt = std.fmt;


@@ 189,7 187,7 @@ pub const Tokenizer = struct {
            switch (self.content[self.index]) {
                // actual whitespace
                ' ', '\t', 0x0B, 0x0C, '\r' => continue,
                '#' => try self.skipPastNewline(),
                '#' => try self.skipToNewline(),
                '\n' => continue,
                else => return,
            }


@@ 203,7 201,7 @@ pub const Tokenizer = struct {
                // actual whitespace
                ' ', '\t', 0x0B, 0x0C, '\r' => continue,
                ';', ',' => continue,
                '#' => try self.skipPastNewline(),
                '#' => try self.skipToNewline(),
                '\n' => continue,
                else => return,
            }


@@ 542,7 540,6 @@ pub const Parser = struct {
    }
};


const testing = std.testing;
const alloc = testing.allocator;



@@ 561,13 558,15 @@ test "key = [ table ]" {
test "duplicate keys overwrite" {
    const zckt =
        \\key = this is a value
        \\
        \\# finally. comments
        \\key = haha! overwritten
    ;

    var table = try Parser.parse(zckt, alloc);
    defer table.deinit();

    testing.expectEqualStrings(table.getString("key").?, "haha! overwritten");
    testing.expectEqualStrings("haha! overwritten", table.getString("key").?);
}

test "multiline string" {