Corn parser implemented in Zig
Find a file
2026-01-23 22:20:38 +01:00
src cleaned up to push to corn.zig repo 2026-01-23 22:08:25 +01:00
.gitignore cleaned up to push to corn.zig repo 2026-01-23 22:08:25 +01:00
build.zig added hash to the readme, cleaned up comments in build.zig 2026-01-23 22:20:38 +01:00
build.zig.zon cleaned up to push to corn.zig repo 2026-01-23 22:08:25 +01:00
LICENSE cleaned up to push to corn.zig repo 2026-01-23 22:08:25 +01:00
README.md added hash to the readme, cleaned up comments in build.zig 2026-01-23 22:20:38 +01:00

Corn.zig

Implementation of the Corn configuration language in the Zig programming language.

Work in progress

This library is currently a work-in-progress and isn't fully ready to be used.

Installation

To the .dependencies section of your build.zig.zon file, add:

.corn = {
  .url = "https://github.com/corn-config/corn.zig/archive/refs/tags/v0.0.1.tar.gz",
  .hash = "corn-0.0.1-K8bW1DfuAABspuvfDhXCTSpINnoY27nKGfUe1hGoS9dn", 
}

then to your build.zig file you can add:

// This assumes you have a fairly-standard build configuration!

const corn = b.dependency("corn", .{
  .target = target,
  .optimize = optimize,
});

exe.addModule("corn", corn.module("corn"));

Usage

const std = @import("std");
const corn = @import("corn");

const assert = std.debug.assert;
const eql = std.mem.eql;

const Cat = struct {
    color: []const u8,
    purring: bool,
};

fn main() !void {
    var gpa: std.heap.GeneralPurposeAllocator(.{}) = .init;
    const allocator = gpa.allocator();
    const input = "{ color = \"orange\" purring = true }";

    const cat = try corn.parseCorn(Cat, input, allocator, null);

    assert(eql(u8, cat.color, "orange"));
    assert(cat.purring);
}