Closed dqsully closed 7 years ago
Hey great stuff! Thank you! I see you are still updating while I tested.
I suppose the regexes won't be able to handle everything but if you'd like to take a look, there are lots of samples in https://github.com/hjson/hjson/tree/master/testCases. For example kan_test
shows errors for "numbers" that Hjson would parse as quoteless strings.
Wow, looking through those test cases I really didn't have this in a finished state at all. I think this time I've got it, but tell me if I missed anything. Some of those test cases were a bit difficult, like allowing the colon for an object property to be on a different line than the key, but regex can handle it, albeit a hacky solution. I hope this works for you.
Also, I've been looking at hjson-rust, as my original intent was to use Hjson and YAML in a Rust REST-like API. I noticed it needed some upgrades, so I've been working on a fork of serde_json to add all of Hjson's features and I think I just about have deserialization done (haven't tested it yet). I probably won't have time to do write any tests, except for maybe simple ones based off of the test cases you mentioned. I also might be able to implement serialization, but it depends on how important it is to my API. If this works though it should be pretty easy to stay up-to-date with serde_json by merging and modifying their changes.
This looks great - the grammar is so much better than the old one - I didn't think it would be possible to get it this good! Thank you!
I hope we can use your work for the other implementations as well (Textmate/Sublime/VSCode are all related but with different syntax files). Do you know if there are any converters? I know apm can convert to Atom but we'd need the other direction.
Regarding hjson-rust - that's great news! I've been trying to get help with the upgrade from serde 0.8 to 1.0. A fresh start is probably easer because of all the breaking changes. Would you mind opening an issue at https://github.com/hjson/hjson-rust/issues? I just emailed with someone who might be able to offer some help as well.
As for converting to VSCode, I've done this with my OctoberCMS template grammar. Usually most of the work should just be converting the grammar into JSON and migrating the grammar's settings. However, there are some discrepancies between how Atom and VSCode do regex matching, so some of the fancy things that I coded for Atom might not work properly in VSCode. ST should be very similar.
As for upgrading hjson-rust, doesn't an issue for this already exist, or do you want me to make another one?
OK, thanks again!
I think I'd rather close the old issue in favor of your new one as it was about upgrading and this is a rewrite.
@dannyfritz could you merge & release and update? thanks
I published it to Atom as v1.0.0
. Thanks! :smile:
Awesome!
@dqsully I updated your syntax on the other plugins as well. Thanks!
This time I rewrote the entire grammar in CSON. The syntax diagrams on your website were really helpful, as well as the parser. I tried to make this new grammar highlight as close to how Hjson is actually parsed, and I think I got pretty close. This new syntax doesn't support an implicit root object, although it might be possible with some tweaks. However, now it highlights invalid characters in objects that don't belong to a key or value, and all of the comments and strings work as they should. The only other thing I can see missing is highlighting duplicate commas.