Pegged, a Parsing Expression Grammar (PEG) generator in D

Andrej Mitrovic andrej.mitrovich at gmail.com
Sat Mar 10 15:56:50 PST 2012


I see you are not the only one who started writing string array
literals like this:

enum PEGCode = grammarCode!(
     "Grammar <- S Definition+ EOI"
    ,"Definition <- RuleName Arrow Expression"
    ,"RuleName   <- Identifier>(ParamList?)"
    ,"Expression <- Sequence (OR Sequence)*"
);

IOW comma on the left side. I know it's not a style preference but
actually a (unfortunate but needed) technique for avoiding bugs. :)

So can you use this to actually parse D code, extract syntax trees and
stuff like that? I'm clueless about parsing but it looks very neat.
Nice work!


More information about the Digitalmars-d-announce mailing list