#text-format #format #parser #human-readable #data-structures #block-header #nested-blocks-format

nbf

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

5 releases

0.2.3 Jun 2, 2023
0.2.2 Jun 1, 2023
0.2.1 Jun 1, 2023
0.2.0 Jun 1, 2023
0.1.0 Jun 1, 2023

#2107 in Parser implementations

MPL-2.0 license

27KB
442 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