www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - D grammar

reply Russel Winder via Digitalmars-d <digitalmars-d puremagic.com> writes:
I should know this, but=E2=80=A6

Is there an official D grammar (EBNF or otherwise) or is the language
defined by the DMD parser?

I am looking to continue Kingsley's DLanguage IntelliJ IDEA plugin and
for that it is necessary to have a grammar specification. Kingsley has
been working on one, but there may be differences between it and 2.071.
Given the compilers and all the supporting tools either there is one
language specification they all work with or there is a lot of
fragmented viewpoints as to what D actually is. I am hoping the latter
is not the case.

--=20

Russel.
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D
Dr Russel Winder      t: +44 20 7585 2200   voip: sip:russel.winder ekiga.n=
et
41 Buckmaster Road    m: +44 7770 465 077   xmpp: russel winder.org.uk
London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
Jun 11 2016
next sibling parent Vladimir Panteleev <thecybershadow.lists gmail.com> writes:
On Sunday, 12 June 2016 at 06:45:58 UTC, Russel Winder wrote:
 I should know this, but…

 Is there an official D grammar (EBNF or otherwise) or is the 
 language
 defined by the DMD parser?

 I am looking to continue Kingsley's DLanguage IntelliJ IDEA 
 plugin and for that it is necessary to have a grammar 
 specification. Kingsley has been working on one, but there may 
 be differences between it and 2.071. Given the compilers and 
 all the supporting tools either there is one language 
 specification they all work with or there is a lot of 
 fragmented viewpoints as to what D actually is. I am hoping the 
 latter is not the case.
Officially, the grammar is defined throughout the specification pages, e.g. on http://dlang.org/spec/grammar.html. Practically, not sure how complete / correct it is, though I know it has been kept up to date by people working on compilers and parsers. Pragmatically, there's this: https://github.com/Hackerpilot/DGrammar
Jun 12 2016
prev sibling next sibling parent reply WebFreak001 <janju007 web.de> writes:
On Sunday, 12 June 2016 at 06:45:58 UTC, Russel Winder wrote:
 I should know this, but…

 Is there an official D grammar (EBNF or otherwise) or is the 
 language
 defined by the DMD parser?

 I am looking to continue Kingsley's DLanguage IntelliJ IDEA 
 plugin and for that it is necessary to have a grammar 
 specification. Kingsley has been working on one, but there may 
 be differences between it and 2.071. Given the compilers and 
 all the supporting tools either there is one language 
 specification they all work with or there is a lot of 
 fragmented viewpoints as to what D actually is. I am hoping the 
 latter is not the case.
There is a full grammar definition on the D Spec pdf file: https://dlang.org/dlangspec.pdf I also converted the whole grammar (excluding Allocator & Deallocator Arguments) with some nicer names to a txt file: https://i.webfreak.org/c5aCpv
Jun 12 2016
parent ketmar <ketmar ketmar.no-ip.org> writes:
On Sunday, 12 June 2016 at 12:14:33 UTC, WebFreak001 wrote:
 There is a full grammar definition on the D Spec pdf file: 
 https://dlang.org/dlangspec.pdf
it is invalid. anyone who will try to write a parser following this grammar only will hit a wall.
Jun 12 2016
prev sibling parent Brian Schott <briancschott gmail.com> writes:
On Sunday, 12 June 2016 at 06:45:58 UTC, Russel Winder wrote:
 I should know this, but…

 Is there an official D grammar (EBNF or otherwise) or is the 
 language
 defined by the DMD parser?

 I am looking to continue Kingsley's DLanguage IntelliJ IDEA 
 plugin and for that it is necessary to have a grammar 
 specification. Kingsley has been working on one, but there may 
 be differences between it and 2.071. Given the compilers and 
 all the supporting tools either there is one language 
 specification they all work with or there is a lot of 
 fragmented viewpoints as to what D actually is. I am hoping the 
 latter is not the case.
If you attempt to give the language specification to a parser generator like ANTLR you will quickly discover that the spec is reverse-engineered from the implementation, and that the spec is ambiguous in many places. The spec, being derived from the implementation is not really aware of the existence of the ambiguities, and doesn't say how to resolve them.
Jun 13 2016