AST like coding syntax. Easy upgrade!

cym13 via Digitalmars-d digitalmars-d at puremagic.com
Sun Sep 6 16:48:29 PDT 2015


On Sunday, 6 September 2015 at 23:40:58 UTC, anonymous wrote:
> On Monday 07 September 2015 00:37, cym13 wrote:
>
>> There already is a kind of "code string":
>> 
>>      interpret(q{
>>           var a = 2;
>>           var b += a;
>>      });
>> 
>> It doesn't do any kind of syntax check, but there again how do 
>> you want to have syntax check for any language? The D compiler 
>> is a D compiler, it can't support js syntax or whatever.
>
> There's a very basic syntax check: Token strings (q{...}) go 
> through tokenization. Compilation fails when the contents 
> aren't valid tokens. For example, q{'} fails with "Error: 
> unterminated character constant".

Then you can't put anything but D-like code... A string is way 
better for that purpose, the q{} gives a handle to the editor and 
I can't see a thing in there that can't (and shoudln't) be done 
at the library level.


More information about the Digitalmars-d mailing list