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

toml v0.2.0 compatibility #9

Closed
navaru opened this issue Feb 21, 2014 · 5 comments
Closed

toml v0.2.0 compatibility #9

navaru opened this issue Feb 21, 2014 · 5 comments

Comments

@navaru
Copy link

navaru commented Feb 21, 2014

I'm trying to fiddle online with peg.js to add support for Tables

I can't quite figure out how to properly do it, if it's not much, please have a look, maybe its something easy for you.

@BinaryMuse
Copy link
Owner

Tables are supported already (previously they were "hashes"), but not arrays of tables. I'll take a look.

@navaru
Copy link
Author

navaru commented Feb 22, 2014

I need it for a configuration setup, where i need to declare multiple resources, so array of tables is the feature I was aiming for.

[[resource]]
name = "file.ext"
type = "video"
path = "path/to/file"

[[resource]]
name = "file.ext"
type = "video"
path = "path/to/file"

Is it hard to add it to the current implementation?

@BinaryMuse
Copy link
Owner

Yeah, it's proving to be a bit tricky for me (note: I am no expert in parsers/compilers). Adding support to the grammar for matching the new syntax is easy enough, and compiling the basic case was easy, but the more advanced example from the TOML spec has proven more difficult.

If you check out the table-arrays branch, you'll find an implementation that works with your example above. There is a test that verifies that

[[resource]]
name = "file.ext1"
type = "video1"
path = "path/to/file1"

[[resource]]
name = "file.ext2"
type = "video2"
path = "path/to/file2"

parses to

{
  resource: [
    { name: 'file.ext1', type: 'video1', path: 'path/to/file1' },
    { name: 'file.ext2', type: 'video2', path: 'path/to/file2' }
  ]
}

I'll have to keep working on the more advanced case, but I don't think I'll finish this weekend. Perhaps this is enough to be usable to you for now; if so, you can point npm directly to commit 6b4dd00. You can see that all the other tests pass here: https://travis-ci.org/BinaryMuse/toml-node/jobs/19452878

@BinaryMuse
Copy link
Owner

I lied :) This works in v2.0.0, which has been published to npm. Please let me know if you have any problems.

@navaru
Copy link
Author

navaru commented Feb 23, 2014

Works great, I really appreciate your effort, thank you! :)

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

No branches or pull requests

2 participants