compile-time access to parsed code
janderson
askme at me.com
Sun Feb 11 13:09:46 PST 2007
Hasan Aljudy wrote:
> alot of ideas for DSL that are coming up are really just additions of
> feature to already existing concepts in D.
>
> For example, mapping a DB table/row to a D class/object.
> One would probably do something like:
> mixin( Model!(
> "Person:
> char[100] name;
> int age;
> ForeignKey(Car) car;
> "
> ))
>
> and then one would have to write a parser for that, which will
> essentially produce a regular D class, with the same attributes, plus
> some additional magic:
>
In this case all the parser would do is find Token: and re-write it as
"class Person" Then find ( and replace it with !(. Finally it would
append the magic on the end. I hope we will eventually get lots of
library functions to help this process out.
This essentially makes the reuseable part easy to write at a cost of
spending a little time writing the Model! library.
In some respects I agree, when I originally posted an idea like this a
few years ago, one of my suggestions asked to have access to D's
symbolic tree passed into the template.
-Joel
More information about the Digitalmars-d
mailing list