Take as example MDN Spider Monkey Parser API web page. You can see that an object returned by a Javascript method is described by a meta-language. The following snippet in that page:
interface Node {
type: string;
loc: SourceLocation | null;
}
Describes an object called Node
which has two properties: type
and loc
. And the following:
interface Program <: Node {
type: "Program";
body: [ Statement ];
}
Describes another object which will inherit properties type
and loc
from Node
plus will have property body
.
About this meta-language
This meta-language is obviously used for documentation purposes as Javascript is not typed, it can get quite tricky to understand what an object exposes when having to deal with it.
Example For example, if I had to document a Javascript object consisting of 3 members: a string, an array of ints and a function, I might go something like:
interface MyObject {
path: string;
indices: [int];
evaluateScore: function;
}
This is a clever way to document Javascript objects exposing certain API! But cannot find a standard here!
Questions I want to know more about this meta-language, but cannot find resources in Internet. However, in order to make this question answerable and not too generic, as starters, please consider the following questions:
- Does this meta-language have a name?
- Is this a possible IDL for JavaScript/JSON?
- Does this meta-language have an official specification?
- If a specification is present, where can i find it?
Thanks
Note
Please note that this question is not about ASTs. I do not care about them! The page I linked just happens to be about ASTs, but that is because I could not find another web page or library documenting their JS stuff using such a meta-language. I just want to know more about the meta-language used by MDN in that page to document their JavaScript objects and what API they expose.