views:

19

answers:

1

I'm looking for a data format for text files with hierarchical information. These files will be created primarily by human input (rather than generated by programs), but will be read primarily by programs. The main requirements are:

  1. Very simple and uncluttered syntax. (Example: levels of hierarchy defined by tabs would work fine.) So simple that the whole language description would fit into a page.

  2. Clean and concise mental model. (Example: tree where leaves are values of types int, string, float, bool, and keys are non-leaf nodes. A slightly more complex model, say with dictionaries, is also ok).

  3. A single way to represent any given semantics; i.e., no equivalent syntax with the same meaning.

  4. Preferably easy to parse in a language like python; or stable libraries available for that purpose.

  5. Can allow some kind of inheritance between files. That is, I would like to allow one file to partially override another. Ideally I'd like to even allow multiple inheritance, with the traditional conflicts of order of resolution handled simply by prohibiting any value to be derived from more than one parent.

  6. Does not create any pitfalls for user-entered data (e.g., unquoted text can be a string in YAML, but if it is a reserved word, then it's not).

Is it something that is available off-the-shelf or do I need to build it from scratch?

YAML doesn't work because it doesn't allow inheritance between files, has pitfalls as described above, and has many alternative syntax constructs to do the same thing.

And YAML / XML doesn't work because the description of neither will fit onto anything like one page.

Thank you!

A: 

I don't know of any data serialization language that satisfies all of those requirements of yours.

I'm very fond of JSON and OGDL (because they are much easier to read then XML), but they both fail (at least) in allowing inheritance.

PS: Wikipedia has a comparison of popular data formats here.

PPS: I guess you should consider writing a DSL. A internal (or weak) implementation would not be that hard to implement, and you could use Python itself as the host language.

rsenna
Indeed, decided to go with DSL...
max