I started working on this project because I need a frontmatter data format for Zine, my static site generator, but I’m trying to make it a general purpose data format that should be an improvement over JSON & co for most similar use cases.
Key features:
distinction between structs vs maps
unions of structs, so that you don’t have to rely on shape matching
I have already created a tree sitter grammar, an LSP and a bunch of parsers for it.
There’s one last feature (custom string literals) that I’m still not fully sure about (mostly syntax-wise) but the two key features above are set in stone.
Try re-imagining some JSON / YAML / TOML files in Ziggy and see if you think they would be improved.
Super cool! I’m stuck using json since it’s a painless communication format between zig and python, and works good enough for first implementation of storage and network systems.
If I ever want to start configuring from json, this would be a neat alternative! Granted json has JSON Schema to do IDE autocomplete, which helps a tonne as well…
I can also imagine this would be nice just to get a quick debug log of some state in a more readable format.
Published a website with a bunch of documentation for Ziggy, I would recommend to the intrepid souls that want to try Ziggy out to download the Ziggy CLI tool and to see if their editor has syntax highlighting support for it.
@kristoff Can I use ziggy’s schema language for a project of mine? It is called freightdb. If yes how can I use it to parse a .ziggy-schema file in zig? The project is still very early into development [it has only been about 2 weeks since development began]
Sure I’ve published Ziggy so that others can use it too.
What is your intent wrt the Ziggy Schema file? If you want to have your application perform schema checking on a Ziggy Schema file, I can give you some pointers. If you want to use a Ziggy Schema to generate automatically a corresponding type, that’s not implemented yet. That said you can give a type to ziggy.parseLeaky and it will work.
Previously I had some random thoughts about using zig struct to as the intermediate format to generate JSON/TOML/YAML etc, even for protobuf, so users don’t need to install the protoc.
Ziggy just make my thought a reality!
By reading its docs, it seems function is not supported?
With function, I think Ziggy can easily generate config with lots of duplicated parts.
The reason why I’m holding off on using comptime to generate types from schemas (or vice versa) is because I want first to explore a codegen path (i.e. using the build system to write the computed artifact as a concrete file in the codebase) because I think it might be a more solid way of doing this work.
Using comptime for schema<>type interop sounds sexy but it has a number of downsides, one of which is the necessity to create comptime parsers and semantic checkers for the schema stuff, which in my opinion constitutes crossing the line of unwise usage of comptime.
So, PRs welcome for a build system based approach if anybody is in a rush, otherwise I will eventually get to it.
As a person looking forward to use the ziggy-schema ina project I will gladly wait for the type generation. I believe you and I believe you will deliver with the type generation