-
Notifications
You must be signed in to change notification settings - Fork 35
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
Autogenerated types? #92
Comments
Yes please would be very useful for my Textmate parser |
Great idea! Please do. Feel free to ask whatever you need. |
Param types for rule generator code can be switched from |
Okay. I have some questions.
|
Hi @siefkenj:
Feel free to create PRs and let's explore it if you want to. |
I think this might be a good time to rethink the architecture of ts-pegjs. I've been looking into doing a PR to add Peggy 3.0 support, but so far I have mostly learned that the code generation in Peggy has changed quite a lot since 2.0. So much so, that it's probably simpler to do a complete rewrite of ts-pegs than to attempt merging in changes from Peggy 3.0. |
Is there a way to convert the pegjs output to an estree & add types to that, then convert back to source? |
Should be possible with recast or jscodeshift. |
Is there a requirement that |
|
(If |
There are limits on TS side on how advanced the generated types can get until they can't be typechecked. The main problem is that whenever you have type-level recursion that goes through a There are two solutions:
In my own parser generator I chose the first approach, because it gives all the AST types for free. There is even a limited support for semantic actions by heavily abusing TS's type system (to the best of my knowledge, this is the only valid use case for |
@pjmolina It appears that the current implementation of Can you confirm my understanding is correct? |
This sounds correct... For now! Even if your |
As of #98 |
I have been working on a project that automatically generates typescript types from a Peggy grammar.
Source is here: https://github.com/siefkenj/peggy-to-ts
Playground is here: https://siefkenj.github.io/peggy-to-ts
If you think this would be good to integrate into
ts-pegjs
, I would be happy to make a PR (but I'd need some guidance about exactly how to integrate it withts-pegjs
, since Peggy doesn't normally produce multiple output files...).The text was updated successfully, but these errors were encountered: