KenKundert / nestedtext

Human readable and writable data interchange format
https://nestedtext.org
MIT License
362 stars 13 forks source link

Convention for expressing the name of the schema used #11

Closed prescod closed 3 years ago

prescod commented 3 years ago

An IDE can determine what "support package" to use for a text file based on its file extension.

An XML editor can determine the same thing based on namespaces or DTD declarations.

I propose that NestedText could document a convention for bootstrapping grammar-driven tools like IDEs, linters, validators, etc.

I offer two suggestions:

  1. Files could have double-extensions of the form config.sls.nt vs config.ans.nt

  2. Files could have a leading comment-line in a predictable format. Arguably it could be a URL which points to the documentation or schema file, which is how it works in XML.

Either way, it should be a universal convention so that tools know where to look. I guess I lean mildly towards the URL strategy because I think it is a good habit to document your grammars and putting the pointer to the documentation in the file makes it easier for both humans and machines to interpret the file.

KenKundert commented 3 years ago

I like the first suggestion. I have included it in documentation for dump(). The second idea seems like it would require modification of the underlying language, and we are trying to keep it as simple as possible for the time being. So we are going to hold off on that one for the time being.