I have been thinking more and more about the need for a light-weight version of YAML, especially after reading https://github.com/toml-lang/toml#but-why, and learning that Rust's new packages manager apparently will be using TOML. There are some things to like about TOML, after all it is essentially the old INI format with a couple of extra features. But it's those extra features that cause me rage --they are down right ugly and confusing.

Anyway, I wanted to see if I could put together a EBNF for a "diet YAML" --basically a YAML without types, complex map keys, etc. Just the basics people use to hand write configuration files and such. How does this look so far:

  Yaml ::= Data*
  Data ::= (Scalar | Sequence | Mapping )
  Scalar ::= (Number | String | Date | Boolean | Nil)
  Sequence ::= (InlineSequence | IndentedSequence)
  InlineSequence ::= "[" Data ("," Data)* "]"
  IndentedSequence ::= OptionalTab "-" Data ("\n" OptionalTab "-" Data)*
  Mapping ::= ( InlineMapping | IndentedMapping )
  InlineMapping ::= "{" Key ":" Data ("," Key ":" Data)* "}"
  IndentedMapping ::= Tab Key ":" Data ("\n" Tab Key ":" Data)*
  OptionalTab ::= Space*
  Tab ::= Space+
  Key ::= Scalar
  String ::= '"' [A-Za-z0-9]* '"' | [A-Za-z0-9]+
  Number ::= ("+" | "-")? [0-9]* ("." [0-9]+)?
  Date ::= [0-9][0-9][0-9][0-9] "-" [0-1][0-9] "-" [0-3][0-9] ( [0-2][0-9] ":" [0-5][0-9] ":" [0-5][0-9] )?
  Boolean ::= "true" | "false"
  Nil ::= "~"
  Space ::= " "

What am I missing? What needs fixing?

Note, you can put this code into http://bottlecaps.de/rr/ui and get a nice picture of it all. Any one else have a good tool for drawing these?


trans