https://github.com/travisstaloch/edn-data
about
edn format is a lispy subset of clojure which i find interesting for its readability and extensibility. maybe its a json, yaml or ziggy alternative.
i started working on this around 6 months ago and it has mostly been a mess. i recently was motivated to add a tokenizer and overall simplify the parsing code. now its in a state where i wanted to share.
i’ve attempted to add extensibility through ‘tagged element handlers’ but i’m not sure of the design details yet. and similar to std.json
, the parser supports arbitrary and structured data plus allows users to override structured parsing by providing a pub fn ednParse()
method.
arbitrary and structured parsing can both be done at comptime.
i plan to use this format in a future state machine codegen lib as shown in examples/Tokenizer.edn.
let me know if you have any use for this data format or thoughts about the lib.
features (paste from readme)
- parsing
- parse arbitrary data with
edn.parseFromSliceAlloc()
oredn.parseFromSliceBuf()
.measure()
is used to determine required buffer sizes forparseFromSliceBuf()
.edn.Options.whitespace
- whether to save whitespace and comments..exclude
means thatParseResult.wss.len
will be 0 and each merged whitespace/comment will be replaced by a single space infmtParseResult()
.
- parse structured data with
edn.parseTypeFromSlice(T)
edn.parseTypeFromSlice(T)
supports custom parsing whenT
provides apub fn ednParse()
. see src/tests.zigtest "ednParse()"
for an example.
- initial support for tagged element handlers. see src/tests.zig
test "tagged handler"
for an example. ParseResult.find()
- access parsed data with simple queries such as'0//1//foo'
. see src/tests.zigtest "ParseResult find()"
for examples.
- parse arbitrary data with
- comptime parsing
- parse arbitrary data with
edn.parseFromSliceComptime()
- parse structured data with
comptime edn.parseTypeFromSlice(T)
- parse arbitrary data with
- formatting
- format parse results with
edn.fmtParseResult(parse_result, src)
- format parse results with