dlang-community / Pegged

A Parsing Expression Grammar (PEG) module, using the D programming language.
534 stars 66 forks source link

Support D's own grammar? #125

Open nesteruk opened 10 years ago

nesteruk commented 10 years ago

Is Pegged preconfigured to parse D itself?

PhilippeSigaud commented 10 years ago

Hello Dmitry,

sorry for the late answer, I was away for some time.

Yes, Pegged comes with a D grammar in the examples/ directory.

See: https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/examples/dgrammar.d

The grammar is mainly a copy of the one of the D website. Caution notice: do not try to generate this parser at compile-time, it's too big. Dump it into a file using as Module

https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/grammar.d#L25

Also, I know the grammar has some mistakes, but I didn't have the time to inspect it entirely.