Hacker News new | ask | show | jobs
by laurent123456 4865 days ago
The format could be very simple, but... allowing comments after values make it unnecessarily complex to parse. For example:

     value = "example # no that's not a comment" # but here's one
If inline comments where not allowed we could just check the first and last character for a quote and we know we have a string, same for arrays (check for [ and ]). But with inline comments, we need to parse the whole string.

As far as I can see both the C# and Python parsers don't handle this kind of comment correctly at the moment, and probably many implementations will have troubles with that. They should just drop this option in my opinion.

2 comments

That's not hard to parse. Inline comments are nice. You'll be doing more reading of files that writing of parsers.
WAT?. Python can parse the above very nicely, thank you.

    >>> value = "example # no that's not a comment" # but here's one
    >>> value
    "example # no that's not a comment"
At the time I wrote that, the only Python parser was removing the comments by splitting the line on "#", which mean it wouldn't work with the example I mentioned.

It seems there are now several other Python parsers, so some of them are probably getting it right.