D parsing

Philippe Sigaud philippe.sigaud at gmail.com
Wed Oct 30 23:10:15 PDT 2013


Do you want to evaluate an expression at CT or to parse an expression?

D has a powerful constant-folding step during compilation, where whole
functions can be evaluated, provided they contain only a subset of D
(almost all of D, except taking adresses/pointers and generating classes,
IIRC).

http://en.wikipedia.org/wiki/Compile_time_function_execution
http://dlang.org/function.html#interpretation


Now, if you want parsing specifically, what do you want to get? A parse
tree? In that case, you can for example use one of my projects, Pegged,
which generates CT-compatible parsers (that is, functions that can use CTFE
to parse a string at CT).
Parse trees can also be manipulated at compile-time, to modify the
expression, and then collapsed down again to a new expression, if that's
what is needed.

https://github.com/PhilippeSigaud/Pegged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20131031/c96c045d/attachment.html>


More information about the Digitalmars-d mailing list