jm / toml

Parse TOML. Like a bawss.
MIT License
151 stars 38 forks source link

Key Group Arrays #22

Closed 88Alex closed 10 years ago

88Alex commented 10 years ago

The TOML v0.2.0 spec, released recently, allows key group arrays with the syntax [[key_group_array]]. This pull request adds a Parslet rule for this. The transformation rule has not yet been implemented.

lessless commented 10 years ago

here is what I have with example from toml github page

[[fruit]]
  name = "apple"

  [fruit.physical]
    color = "red"
    shape = "round"

  [[fruit.variety]]
    name = "red delicious"

  [[fruit.variety]]
    name = "granny smith"

[[fruit]]
  name = "banana"

  [[fruit.variety]]
    name = "plantain"
TOML.load_file('1.toml')
RuntimeError: Unrecognized part: {:key_groups=>[{:key_group_name=>"fruit"@2, :keys=>[#<TOML::Key:0x00000001d831b8 @key="name", @value="apple">]}]}
    from /tmp/toml/lib/toml/parser.rb:36:in `block in initialize'
    from /tmp/toml/lib/toml/parser.rb:21:in `each'
    from /tmp/toml/lib/toml/parser.rb:21:in `initialize'
    from /tmp/toml/lib/toml.rb:24:in `new'
    from /tmp/toml/lib/toml.rb:24:in `load_file'
    from (irb):2
    from /home/lessless/.rvm/rubies/ruby-2.0.0-p247/bin/irb:13:in `<main>'
88Alex commented 10 years ago

That's because I've only written the Parslet rule, not the actual code that handles it.

parkr commented 10 years ago

@88Alex Maybe you can add in "todo's" here with GitHub's checkbox list Markdown syntax, or throw a NotImplementedError if the key group has been parsed properly but can't be handled yet.

88Alex commented 10 years ago

@parkr Thanks for the suggestion, now the transformer rule throws NotImplementedError.

lessless commented 10 years ago

what about implementing parsing itself? ;)