KernelDeimos 2bf9f60bb0 dev(license-headers): implement skip and replace 3 月之前
..
README.md 50036e954d dev: add js-parse-and-output experiment 3 月之前
package.json 50036e954d dev: add js-parse-and-output experiment 3 月之前
test.js 2bf9f60bb0 dev(license-headers): implement skip and replace 3 月之前

README.md

Parsing Javascript and Generating it Back

What Purpose?

This would be really useful for refactoring tools. I also want automatic comments to be placed when certain features are used, such as the Sequence class, since its usefulness won't be immediately apparent where it appears in the source code.

I turns out the state of affairs with respect to generating a CST for javascript... kind of sucks. I hope that further discussion on the issue I linked renders the previous statement ironic.

So, What Next?

The options I see are:

  1. Add support to recast to make use of @babel/parser tokens when the tokens: true option is set.
  2. Add a format-preserving outputter to @babel/outputter. this is being worked on
  3. Wait for someone else to do either of the previous two things.
  4. Write a CST parser for javascript.

I'm going to start with option #3. It's very disappointing that I don't have time to do #4, because I don't very much like solutions #1 and #2; I like my CSTs to be more cohesive - a pyramid of meaning - rather than lexer output dumped at the end of an AST.