-
-
Notifications
You must be signed in to change notification settings - Fork 63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example usage? #647
Comments
Not sure what specific purpose you have, but there is a work to prettify IDL using this library: https://github.com/w3c/respec/blob/e6d12149e82106fb3c034c1f7bd0735ae9075aff/src/core/webidl.js#L27-L131
It's not that the types are private, it's just that the type library is not up to date 🥲 (#255) |
It's not about the types being private, it's about not having to manually check types as in
Whether I use As for what I'm trying to do. I'm trying to generate a nested display. So for example if I have
Then I want to generate something like
Maybe a large set of ifs handling each different AST type is what I need but it seemed like maybe there was a better way I'm missing |
Hmm, could you provide a pseudo-code that you expect to work? I can see what others do (babel etc.) and follow them, but understanding your specific requirement will probably be more helpful. |
Sorry, I'm not sure what I'm looking for 😅 I was just asking of there was more I was overlooking. AFAIK, as it is, if I want to do what I wrote above I have to dig into the internals of the classes Anyway, I don't want to ask for any work on your part. I'll try to figure out a solution with what's there and then maybe I can suggest a solution and a PR if one comes up. |
WebIDL2.js exposing a traversal API would sure be nice |
This is kinda done in the writer API, you can theoretically use the writer API and then ignore the return value. |
Is there docs or an example of using this to look at the AST externally?
What I mean is, looking in the code,
write
ends up calling each object's privatewrite
function. Effectivelyparse(idl).map(t => t.write());
but let's say I wanted to generate HTML. How would I go about doing this? All the types are private and so I end up looking at random fields to try to guess the type. Even if I could branch on the type (as inif (x instanceof Typedef)
etc that seems very hacky (lots of ifs)Is there some helper to help me walk the AST to visit each node or an example of doing so?
The text was updated successfully, but these errors were encountered: