Various general questions #158
|
Hi all, Landed here while seeking for a base standard format to represent AST of various languages. Wondering if Unist is standard enough is a matter of how widely it is used, so I guess it's difficult to answer this. For JavaScript at least, there already is ESTree. It seems well adopted as a standard but it's only for JavaScript. How a JavaScript specialization of Unist (if there is one) compares with ESTree? Edit: ESTree seems to be more designed as an API, not as a representation, so this comparison may be difficult. Edit2: yes, there is one: esast. Is there a directory where all language specializations are registered? Is there something to help diverging by language specialization to converge? I mean with a place to talk about what is missing or may not be up to date regarding a language’s reference, etc. The question is about the standard representation, not about the toolings. Edit: seems syntax-tree is already about this? Is there a way to keep comments with their original formatting? Is there some common documentation idiom to mention semantics? Or may be generated nodes (I’ve seen mentioned in the README) already have this purpose? Some (not all) semantic aspects of most languages, could be represented by simple relations, indeed (ex. that name refers to this declaration or object, this name belongs to that scope, are examples). Is it expected to be used outside of the web languages world? (CSS, HTML, JavaScript, Markdown, etc) I feel to remember, a long time ago, I learned about an XML standard to represent AST of numerous languages, but cannot find it anymore. Do anyone remember this? May be it has disappeared … :-/ Or may be it's me confusing with something else. With many thanks … |
Replies: 3 comments 6 replies
|
Welcome @Hibou57 ! 👋
What do you mean by standard enough?
Many are on the
It is
That's language specific.
Sure it can be.
We aren't that XML standard, unist is JSON based. 🙂 |
|
Hello and thanks for the responses,
An examples is JavaScript and JSDoc, and the JSDoc are using TypeScript types syntax but it is JavaScript, not TypeScript which is only used for type checking. It's for documentation, not type checking which is left to TypeScript.
As an example, it would not be well suited to a language like SML ? Will have a look at the three links you suggested (searched, but did not find these, while feel to remember the first one a long time ago) I had another question and may avoid opening another discussion for that. Since there is a format to represent an AST for a language, there a parsers producing this. It makes think about test suits. This would be profitable to everyone and could help discussing in case of differing output. I noted Unist is more JSON than XML, but with XML there is Canonical XML to ease comparison. May be there is something similar with JSON or could be defined. Test suits, does it already exists or is there any provision for it? Edit: it would be useful even to projects not necessarily based on unist, but which could be related to it in this way, and contribute to it in that aspect. Have nice day and wish you the weather is not too hot |
|
More about the last question. More limited, but may be an option: the Language Server Protocol. It does not expose an AST (and it does not on purpose), but allows queries on a source. Providing the possible queries are enough for some intent, it is at least interoperable. For the last question, I will have a look into that direction, different from the one I was devising first. |
Welcome @Hibou57 ! 👋
I'd recommend starting by reading it answers a lot of these questions https://unifiedjs.com/learn/
What do you mean by standard enough?
It is widely used? Matter of perspective?
remark(mdast) alone gets 19 million downloads a week. I'd say that's pretty well adopted.Many are on the
unisttopic on GitHub https://github.com/topics/unistIt is
That's language specific.
Wh…