ES6 Parser in Dlang

drug drug2004 at bk.ru
Fri Feb 28 05:24:16 UTC 2020


28.02.2020 01:22, Sebastiaan Koppe пишет:
> On Thursday, 27 February 2020 at 14:06:19 UTC, James Lu wrote:
>> I want to implement an ES6 (JavaScript) parser in Dlang so I can 
>> implement a transpiler. Because it's a transpiler, I need to be able 
>> to visit and rewrite AST nodes, then generate code from the AST. 
>> Ideally, the parser generator supports streaming the input into the 
>> AST visitor out to the output.
>>
>> What parser generator library should I use for this purpose?
> 
> I dunno. I wrote the es6-grammar library that uses pegged. Then I 
> decided to hand write mine own.

What was the reason? Pegged parsing errors?

> 
> https://github.com/skoppe/jazr
> 
> It is a pretty complete and fast JS minifier. It has lots of passes and 
> minifies code pretty well:
> 
> https://github.com/skoppe/jazr/blob/master/source/es6/minifier.d#L286
> 
> In general it is about 30 times faster than uglify-js (and uses 3-4 
> times less memory). It parses JS code at about 60 Mb/s. The minifier was 
> a bit slower at 20 Mb/s if I remember correctly.
> 
> I fuzzed the lexer and parser, so there are little to no spurious 
> crashes on weird input.
> 
> Use it as you please, or just as an indication of the effort involved.



More information about the Digitalmars-d mailing list