ES6 Parser in Dlang

Sebastiaan Koppe mail at skoppe.eu
Fri Feb 28 07:30:39 UTC 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.


More information about the Digitalmars-d mailing list