D grammar

Joerg Joergonson via Digitalmars-d digitalmars-d at puremagic.com
Tue Jun 14 10:27:21 PDT 2016


On Tuesday, 14 June 2016 at 13:23:37 UTC, Jacob Carlborg wrote:
> On 2016-06-14 11:31, Russel Winder via Digitalmars-d wrote:
>> Thanks to Vladimir Panteleev, WebFreak001, ketmar, and Brian 
>> Schott for
>> replying to my email about a grammar specification for D 
>> usable for
>> IDEs and other tools.
>>
>> It seems that the D language is defined not by a 
>> re-purposable, machine
>> readable grammar specification, but solely by the DMD 
>> compiler, the
>> parse of which is not defined by a re-purposable, machine 
>> readable
>> grammar. Thus any grammar specification that is created is 
>> unlikely to
>> be correct and so all tooling and IDE support has to be based 
>> on
>> incorrect data. Given the biggest problem with D is, according 
>> to the
>> recent survey, tooling and IDE support, you get the feeling 
>> this is not
>> an enviable position for a programming language to be in.
>
> How many IDE's/editors do actually use something like EBNF? I 
> know TextMate doesn't. It uses some kind of rules with extended 
> regular expressions (simplified explanation).

It doesn't matter because once you have a well defined grammar 
you can convert it to any other format you wish.  The point is 
that D has no well defined grammar because it's all mashed up in 
the parsing and compiling itself.

I wonder if someone could write a program generator that 
generates random valid D code from one of these grammars and runs 
it in DMD to find compilation errors.

It shouldn't be too hard to do and only needs to provide coverage 
of the grammar, not all possible programs. This might help 
validate a grammar(could be designed to be generic and for other 
parsing tools).




More information about the Digitalmars-d mailing list