AST like coding syntax. Easy upgrade!

Adam D. Ruppe via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 6 13:38:43 PDT 2015


On Sunday, 6 September 2015 at 20:22:23 UTC, Zoadian wrote:
> obviously X has to be a compiletime js->d compiler.

Just a fun fact: my script.d's interpreter is itself CTFEable in 
modern dmd!


import arsd.script;

void main() {
         // script.d is similar to but not identical to javascript
         // so run that code in the interpreter and fetch a D
         // type right out all at compile time...
         enum a = interpret("var a = 5; a += 2; a;").get!int;
         pragma(msg, a);
}


$ dmd d ~/arsd/jsvar ~/arsd/script
7


jsvar.d and script.d can be found here:
https://github.com/adamdruppe/arsd


More information about the Digitalmars-d mailing list