#parser #text-format #format #human-readable

nbf

Draft implementation of the Nested Blocks Format, which is a human-friendly text format for expressing nested or hierarchical data

9 releases (3 stable)

1.1.0 Oct 1, 2024
1.0.1 Sep 28, 2024
0.4.0 Sep 26, 2024
0.2.3 Jun 2, 2023
0.1.0 Jun 1, 2023

#871 in Parser implementations

Download history 6/week @ 2024-07-26 2/week @ 2024-08-02 85/week @ 2024-09-20 466/week @ 2024-09-27 47/week @ 2024-10-04 6/week @ 2024-10-11 1/week @ 2024-10-18

602 downloads per month

MPL-2.0 license

30KB
517 lines

NBF Nested Blocks Format

Licensed under the Mozilla Public License, version 2.0.

About

This crate provides a draft implementation of a parser for the "Nested Blocks Format" (short NBF). NBF is a text file format, which is specifically designed for humans to be able to express nested or hierarchical structures in the form of blocks. For details check out the documentation.


lib.rs:

This crate contains a draft implementation of the Nested Blocks Format (NBF), which is a human friendly format that allows expressing nested or hierarchical data. The basic unit in NBF is a block, containing zero or any number of nested children:

block type: name of first block {
    another block type: name of nested block {
    }
}
block type: name of second block

In this example block type is the type of the two outer blocks, also referred to as the block's key word(s). name of the first block is the first block's header value. The first outer block has a singe child, whereas the second block has no children. (Brakets may be omitted whenever a block has no children.)

For a real example, a dataset in NBF might look like:

person: Albert Einstein {
    year of birth: 1879
}
person: Max Planck {
    year of birth: 1858
}

The two given blocks which define persons contain the inner blocks (without brakets)

year of birth: 1879

and

year of birth: 1858

There is no limit to the nesting, except for the limits which the user imposes in his or her implementation. For instance, a person could also have one or multiple address blocks assigned:

person: Richard Feynman {
    year of birth: 1918
    address: home {
        street name: ...
        street number: ...
        city/town/village: ...
        county/state: ...
    }
    address: work {
        street name: ...
        street number: ...
        city/town/village: ...
        county/state: ...
    }
}

For details of the implementation see the parser module.

No runtime deps