CST explorer?
- Dominant language
- JavaScript
- Stars
- 6.5k
- Forks
- 772
- PR merge metrics
- No merged PRs in 30d
Description
I've spent the last few months working on a tool, [cst-tokens](https://github.com/js-cst-tokens/cst-tokens), that I believe will serve as a replacement for recast.
The idea of cst-tokens is to implement the basics of code transformation without any language or parser-specific logic. **This could give AST explorer the ability to allow users to easily write transforms for every single language it has a supported parser for!**
To do this each parser would need an associated cst-tokens grammar. This isn't as much of a problem as it sounds like because those grammars don't need define complete parsing logic. Instead a grammar just expresses (in essence) what the valid ways of printing a given AST might be. The cst-tokens engine can then use the grammar to recombine a given AST with its source text while tokenizing and attaching the tokens to the nodes they conceptually belong to. Because of the way the problem is simplified, a single grammar can be used to support every estree-compliant parser at the same time (including Babel which is only sort of compliant).
While all this is cool, it creates some architectural problems. cst-tokens isn't really a parser itself. It doesn't belong in the list of parsers. When it's active though, it needs to decorate/replace the tree that the active parser has generated. I don't know enough about how the AST explorer code is structured yet to understand what this would take to implement.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.