Re:Bublé: a fast, batteries-included ES2015 transpiler
by rtpg on Monday May 16, 2016 @02:48AM
(#11704676)
it sounds like they're still generating an AST, but replacing AST nodes directly through the code string.
It's definitely trickier but I think it's possible to do this in a clean way if the changes are just "replace this AST node with this other AST node". You know the text boundaries, and the output is context free so...
Re:Bublé: a fast, batteries-included ES2015 transpiler
by rich_harris on Monday May 16, 2016 @09:12AM
(#11706004)
> Is that really good idea when looking at the possibility of introducing bugs in the transpiler?
That's what a test suite is for :)
Re:Bublé: a fast, batteries-included ES2015 transpiler
by aspiringuser on Monday May 16, 2016 @10:03AM
(#11706290)
Surely the AST is still produced? Acorn is the parser I assume?
Re:Bublé: a fast, batteries-included ES2015 transpiler
by rich_harris on Monday May 16, 2016 @11:35AM
(#11706953)
Correct – Acorn is a truly wonderful library
Re:Bublé: a fast, batteries-included ES2015 transpiler
by Touche on Monday May 16, 2016 @11:55AM
(#11707132)
Hey Rich, I wish some time you would write more about magic-string and what makes it special. You say "no costly code generation step", but what makes codegen costly compared to what you're doing in magic-string?
Re:Bublé: a fast, batteries-included ES2015 transpiler
by rich_harris on Monday May 16, 2016 @01:36PM
(#11707974)
I plan to write about this in the near future (in fact I'm writing slides for a talk on it this week) – essentially, codegen is more costly because a) you have to generate the entire program, rather than just modifying the nodes that have changed, b) your code generator needs to know about every single node type, and c) you have to keep track of state (e.g indentation levels).
Is that really good idea when looking at the possibility of introducing bugs in the transpiler?