Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Key Group Arrays #22

Closed
wants to merge 10 commits into from
Closed

Key Group Arrays #22

wants to merge 10 commits into from

Conversation

88Alex
Copy link

@88Alex 88Alex commented Sep 25, 2013

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.

I edited the rule(:key_value) so spaces are not required before and after the =.
This way, "key=3" would pass.
I modified the Parslet rules to make everything ignore spaces. This way, `myArray=[1,2,3,4,5]` passes.
In the TOML v0.2.0 specs, keygroups are now called tables.
In accordance with the TOML v0.2.0 specs, arrays of tables are now allowed. This commit satisfies that requirement.
Switching to "tables" would be too complicated.
@lessless
Copy link

lessless commented Oct 8, 2013

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
Copy link
Author

88Alex commented Oct 10, 2013

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

@parkr
Copy link
Collaborator

parkr commented Oct 10, 2013

@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
Copy link
Author

88Alex commented Oct 10, 2013

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

@lessless
Copy link

what about implementing parsing itself? ;)

@dirk dirk closed this in 59fb998 Oct 19, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants