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

Jay Norwood jayn at prismnet.com
Mon Mar 12 22:25:37 PDT 2012


>>
>
> Admittedly I have not heard of PEGs before, so I'm curious: Is 
> this powerful enough to parse a language such as C?

I've just read a few articles referenced from this page, and the 
second link was by someone who had done java 1.5, the second link
http://bford.info/packrat/
http://www.romanredz.se/papers/FI2007.pdf

It is interesting but that article left me with some questions 
about the implementation in order to make it useful for my needs.

I had done an experiment with mvel expression evaluation in java 
and gotten good improvements relative to homebrew expression 
evaluators.

However, the mvel expressions are missing the ability to express 
array operations clearly, which is something that is very clear 
in D, and my particular need is to enable the user to express 
array operations.

With this pegged embedded parser, it appears to me you could 
provide a group of  context symbols as part of a language 
definition, similar to providing a list of reserved words, so 
that the parsing of the user's expression would also validate the 
symbols used.

Also, I've been reading David Simcha's parallel_algorithm.d, here:
https://github.com/dsimcha/parallel_algorithm/blob/master/parallel_algorithm.d
and in the parallelArrayOp portion, he has presented a way to 
turn the D array expressions into code that is executed in 
parallel on multicore systems. That is something I'd want to use, 
but the manual lexing requirement is a bit clunky, and the rules 
are unclear to me,  so it seems to me a combination with the 
pegged parser could make that more accessible.
Thanks,
Jay








More information about the Digitalmars-d-announce mailing list