What does HackerNews think of Pegged?

A Parsing Expression Grammar (PEG) module, using the D programming language.

Language: D

Here's a parser generator that uses metaprogramming in D to run it at compile time:

https://github.com/PhilippeSigaud/Pegged

This is the intended purpose of the feature. gzip may be a little aggressive given that you have to unzip it again at the other end but its very possible (and potentially not even as expensive as one might expect given that these types of compression algorithms can be tuned on a speed/size tradeoff and backoff when struggling to compress).

https://github.com/PhilippeSigaud/Pegged is a D library that generates a parser generator for you based on a grammar (string) at compile time.

This is an excellent Packrat parser library in the D language:

https://github.com/PhilippeSigaud/Pegged

If you want to understand the compile-time techniques available in D language that are being used by the Pegged library this is a handy guide:

https://wiki.dlang.org/User:Quickfur/Compile-time_vs._compil...

I've written a couple parsers in D using https://github.com/PhilippeSigaud/Pegged and they seem pretty fast and easy to verify. Of course since it generates a lot of code at compile time, you can end up with somewhat slow builds.
I'm just happy that D was mentioned. Yay, D! Also, D's metaprogramming is an utter joy, almost lisp-like, without the craziness of C++ templates. Give it a try!

An intro to one ingredient of the magic of D metaprogramming, compile-time function evaluation:

https://tour.dlang.org/tour/en/gems/compile-time-function-ev...

An example of the kind of introspection available in the D stdlib:

https://wiki.dlang.org/Finding_all_Functions_in_a_Module

This one's really cool, a library that lets you build an entire grammar of your choice and evaluate it at compile time:

https://github.com/PhilippeSigaud/Pegged

Nim's metaprogramming seems quite similar, and I sometimes wonder if perhaps it took some inspiration from D.

Pegged - PEG generator implemented in the D programming language https://github.com/PhilippeSigaud/Pegged , works in run-time or compile-time
> https://groups.google.com/forum/#!msg/golang-dev/ZTD1qtpruA8...

Everything in there listed as impractical in Go is possible in D without external tool, with just regular meta-programming:

- generating parsers from grammar https://github.com/PhilippeSigaud/Pegged

- embedding files as array of bytes:

    ubyte[] = import("file.jpeg");\n
\n- protobuf files at compile-time: https://github.com/msoucy/dproto

- generating tables at compile-time with CTFE

Instead of copying what works the Go leaders pretend it doesn't work.

> Everyone uses regexes; using a lexer generator should (in my opinion) be as easy as using a one-off regex. I think the key is to make the lexer generator an embeddable library like regex libraries are.

There actually is a really powerful parser generator for D by Philippe Sigaud: https://github.com/PhilippeSigaud/Pegged It's much more pleasant to use than something like Boost Spirit.

Somewhat relatedly, D's standard library has a compile time regex engine that compiles regular expressions down at compile-time resulting in some of the fastest regular expressions in the world.