February 28, 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.

February 28, 2020
On Friday, 28 February 2020 at 05:24:16 UTC, drug wrote:
> 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?

No, it was mainly speed and memory usage.

Pegged is pretty convenient for small grammar or small input files, but es6-grammar contains about 500 grammar rules and I was running it on Mb's of javascript.

Incidentally I improved pegged's parsing errors in https://github.com/PhilippeSigaud/Pegged/pull/269 you now get a much more complete parsetree on errors. Bastiaan, however, found some memory usage problems but I hope to tackle them soonish.
February 28, 2020
On 2/28/20 10:30 AM, Sebastiaan Koppe wrote:
> 
> No, it was mainly speed and memory usage.
> 
> Pegged is pretty convenient for small grammar or small input files, but es6-grammar contains about 500 grammar rules and I was running it on Mb's of javascript.
> 
> Incidentally I improved pegged's parsing errors in https://github.com/PhilippeSigaud/Pegged/pull/269 you now get a much more complete parsetree on errors. Bastiaan, however, found some memory usage problems but I hope to tackle them soonish.

Yes, I've seen your PR so I asked this question) Nice work!

I'm curious can Pegged be improved to be usable in industry and become standard parser generator in D land de-facto.

February 28, 2020
On Friday, 28 February 2020 at 07:53:22 UTC, drug wrote:
> Yes, I've seen your PR so I asked this question) Nice work!

thx

> I'm curious can Pegged be improved to be usable in industry and become standard parser generator in D land de-facto.

It is already used in industry. Rather successfully I would say.

Making and keeping something a de-facto standard requires a lot of work spread over years, I don't see that happening.
March 02, 2020
On Thursday, 27 February 2020 at 22:22:59 UTC, Sebastiaan Koppe wrote:
>
> I dunno. I wrote the es6-grammar library that uses pegged. Then I decided to hand write mine own.
>
> 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.

Thanks. I will use this to create wrappers that ensure JS closures can be serialized.
1 2
Next ›   Last »