Here is an example I made in a few minutes:
ports:
- 80
- 8000 - 10000
- 12000 -
- 14000
Guess how it parses? answer: {"ports":[80,8000,10000,12000,[14000]]}Here is an example I made in a few minutes:
ports:
- 80
- 8000 - 10000
- 12000 -
- 14000
Guess how it parses? answer: {"ports":[80,8000,10000,12000,[14000]]}This is roughly equivalent to saying that a linter can transform the AST of the language into a canonical representation, and the syntax will be rejected unless it matches the canonical representation (modulo things like comments or whitespace-for-clarity).
I don't think warnings will be part of the spec, though classes of errors may be specified (TBD). This will allow, for instance, implementations that prioritize pure speed by leaving all the guardrails off and simply replying "NO." when they are unable to parse some KSON (and then possibly falling back to a parse with richer validations?).
But languages are more than syntax, they are also the ecosystem of tools around the language. And for a language to be useful and reliable, that ecosystem of tools needs to be excellent, and it needs to be available on any platform you want to use that language. That's a really important motivator for KSON's multiplatform architecture, which allows us to reach all these platforms[2] and editors[3] (with even more to come!)
[1] https://github.com/kson-org/kson/blob/857d585ef26d9f73e080b5... [2] https://kson.org/docs/install/#languages [3] https://kson.org/docs/install/#editor-support
i.e. until that "formal grammar" which is currently a comment in a Kotlin source file ;) becomes a versioned and reference-able spec that can be implemented by third-parties this is all a bit of a cart/horse dilemma i think maybe
To see misleading indentation warnings in action, you can try the following snippet in the playground (https://kson.org/playground/) and will properly get a warning:
ports:
- 80
- 8000
- 10000
- 12000
- 14000
Next to that, note that KSON already has an autoformatter, which also helps prevent misleading indentation in files.If your config format requires autoformatter and/or linter to detect trivial mistakes, it is junk.
IMO this way of thinking disqualifies lots of legitimate configuration formats, but to each their own I guess.
When I think about it, any language should come with a strict, non-configurable built-in formatter anyways.
Would that be on the language, or the IDEs that support it? Seems out of scope to the language itself, but maybe I'm misunderstanding.
If you supposedly human writable config file format is unusable without external tools, there is something wrong with it.
Just use a formatter and stop bikeshedding please.
And KSON is pretty unique in how bad is it. For example, go to playground and remove a single dot in line 11 (after the books list). Look how the parse tree changes - this 1-character edit means the file is still valid, but the rest of the file is now filed under one of the books.
Do you know of any other config language with this property - a single character removed yields a syntactically correct file which yet parses absolutely incorrectly? I don't. Worst I can think of is maybe one section parses weirdly, or next element of a list. But something like _entire rest of file_ is broken is unique to KSON.
Btw, I love JetBrain's SSH sync for keeping my config files in VCS and editing them with proper tooling.