www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - EBNF grammar for D?

reply "Philippe Sigaud" <philippe.sigaud gmail.com> writes:
Hello,

I'm looking for a D grammar in (E)BNF form. Did any of you write 
something like that or do you think I can use the grammar parts 
on dlang.org?


I remember different threads on this subject and saw the docs 
being updated regularly on github, but my google-fu is weak today.
Mar 11 2012
parent reply Alix Pexton <alix.DOT.pexton gmail.DOT.com> writes:
On 11/03/2012 16:49, Philippe Sigaud wrote:
 Hello,

 I'm looking for a D grammar in (E)BNF form. Did any of you write
 something like that or do you think I can use the grammar parts on
 dlang.org?


 I remember different threads on this subject and saw the docs being
 updated regularly on github, but my google-fu is weak today.
Rainer Schuetze pulled all the grammar out of the docs and fixed them up a while back as part of his work on Visual D. Its not in straight EBNF and it may not be 100% up to date, but it may be a good place to start. http://www.dsource.org/projects/visuald/wiki/GrammarComparison I hope that is of some use! A...
Mar 12 2012
next sibling parent reply Rainer Schuetze <r.sagitario gmx.de> writes:
On 3/12/2012 11:17 AM, Alix Pexton wrote:
 On 11/03/2012 16:49, Philippe Sigaud wrote:
 Hello,

 I'm looking for a D grammar in (E)BNF form. Did any of you write
 something like that or do you think I can use the grammar parts on
 dlang.org?


 I remember different threads on this subject and saw the docs being
 updated regularly on github, but my google-fu is weak today.
Rainer Schuetze pulled all the grammar out of the docs and fixed them up a while back as part of his work on Visual D. Its not in straight EBNF and it may not be 100% up to date, but it may be a good place to start. http://www.dsource.org/projects/visuald/wiki/GrammarComparison I hope that is of some use! A...
There is also a script to generate the grammar text file here: http://www.dsource.org/projects/visuald/browser/grammar I have not run it lately, though.
Mar 12 2012
parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
Rainer Schuetze
 There is also a script to generate the grammar text file here:

 http://www.dsource.org/projects/visuald/browser/grammar
The resulting text file is quite good. Heck, I think I could modify a parser generator I'm writing to accept it directly. I'll use that also, thanks for your work, Rainer.
Mar 12 2012
prev sibling next sibling parent reply bcs <bcs example.com> writes:
On 03/12/2012 03:17 AM, Alix Pexton wrote:
 On 11/03/2012 16:49, Philippe Sigaud wrote:
 Hello,

 I'm looking for a D grammar in (E)BNF form. Did any of you write
 something like that or do you think I can use the grammar parts on
 dlang.org?


 I remember different threads on this subject and saw the docs being
 updated regularly on github, but my google-fu is weak today.
Rainer Schuetze pulled all the grammar out of the docs and fixed them up a while back as part of his work on Visual D. Its not in straight EBNF and it may not be 100% up to date, but it may be a good place to start. http://www.dsource.org/projects/visuald/wiki/GrammarComparison I hope that is of some use! A...
IIRC the grammar in the docs has tended to be out of date one in a while. I'd love to see the source for the grammar rules become the parser source (either generating the parser from a grammar, generating a grammar from the parser or embed the documentation of each grammar rule in the comments next to the code that implements it).
Mar 12 2012
parent reply James Miller <james aatch.net> writes:
On 13 March 2012 16:02, bcs <bcs example.com> wrote:
 On 03/12/2012 03:17 AM, Alix Pexton wrote:
 On 11/03/2012 16:49, Philippe Sigaud wrote:
 Hello,

 I'm looking for a D grammar in (E)BNF form. Did any of you write
 something like that or do you think I can use the grammar parts on
 dlang.org?


 I remember different threads on this subject and saw the docs being
 updated regularly on github, but my google-fu is weak today.
Rainer Schuetze pulled all the grammar out of the docs and fixed them up a while back as part of his work on Visual D. Its not in straight EBNF and it may not be 100% up to date, but it may be a good place to start. http://www.dsource.org/projects/visuald/wiki/GrammarComparison I hope that is of some use! A...
IIRC the grammar in the docs has tended to be out of date one in a while. I'd love to see the source for the grammar rules become the parser source (either generating the parser from a grammar, generating a grammar from the parser or embed the documentation of each grammar rule in the comments next to the code that implements it).
I agree, automatic generation of the grammar rules would be incredibly useful for D tools. It doesn't necessarily have to be in a human-readable format, or even in a specific grammar format, just up to date. We can always have something to convert it into a specific format for whatever we are doing. We are programmers after all. -- James Miller
Mar 12 2012
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 3/12/12 10:36 PM, James Miller wrote:
 I agree, automatic generation of the grammar rules would be incredibly
 useful for D tools. It doesn't necessarily have to be in a
 human-readable format, or even in a specific grammar format, just up
 to date. We can always have something to convert it into a specific
 format for whatever we are doing. We are programmers after all.
I think being up-to-date is becoming less of a matter now that the language is stable. Changes in syntax are already very rare. Andrei
Mar 12 2012
parent reply James Miller <james aatch.net> writes:
On 13 March 2012 16:47, Andrei Alexandrescu
<SeeWebsiteForEmail erdani.org> wrote:
 On 3/12/12 10:36 PM, James Miller wrote:
 I agree, automatic generation of the grammar rules would be incredibly
 useful for D tools. It doesn't necessarily have to be in a
 human-readable format, or even in a specific grammar format, just up
 to date. We can always have something to convert it into a specific
 format for whatever we are doing. We are programmers after all.
I think being up-to-date is becoming less of a matter now that the language is stable. Changes in syntax are already very rare. Andrei
True, in that case we need to make sure we actually have a completely up to date grammar for the language somewhere then. All in one place. -- James Miller
Mar 12 2012
parent reply =?UTF-8?B?QWxleCBSw7hubmUgUGV0ZXJzZW4=?= <xtzgzorex gmail.com> writes:
On 13-03-2012 05:00, James Miller wrote:
 On 13 March 2012 16:47, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org>  wrote:
 On 3/12/12 10:36 PM, James Miller wrote:
 I agree, automatic generation of the grammar rules would be incredibly
 useful for D tools. It doesn't necessarily have to be in a
 human-readable format, or even in a specific grammar format, just up
 to date. We can always have something to convert it into a specific
 format for whatever we are doing. We are programmers after all.
I think being up-to-date is becoming less of a matter now that the language is stable. Changes in syntax are already very rare. Andrei
True, in that case we need to make sure we actually have a completely up to date grammar for the language somewhere then. All in one place. -- James Miller
Visual D's parser would be a good place to start, I suppose. -- - Alex
Mar 12 2012
parent reply Andrei Alexandrescu <SeeWebsiteForEmail erdani.org> writes:
On 3/12/12 11:03 PM, Alex Rønne Petersen wrote:
 On 13-03-2012 05:00, James Miller wrote:
 On 13 March 2012 16:47, Andrei Alexandrescu
 <SeeWebsiteForEmail erdani.org> wrote:
 On 3/12/12 10:36 PM, James Miller wrote:
 I agree, automatic generation of the grammar rules would be incredibly
 useful for D tools. It doesn't necessarily have to be in a
 human-readable format, or even in a specific grammar format, just up
 to date. We can always have something to convert it into a specific
 format for whatever we are doing. We are programmers after all.
I think being up-to-date is becoming less of a matter now that the language is stable. Changes in syntax are already very rare. Andrei
True, in that case we need to make sure we actually have a completely up to date grammar for the language somewhere then. All in one place. -- James Miller
Visual D's parser would be a good place to start, I suppose.
I'd love to embed a D parser inside Phobos, even though it's not the implementation used inside the compiler. Andrei
Mar 12 2012
parent "H. S. Teoh" <hsteoh quickfur.ath.cx> writes:
On Mon, Mar 12, 2012 at 11:10:14PM -0500, Andrei Alexandrescu wrote:
[...]
 I'd love to embed a D parser inside Phobos, even though it's not the
 implementation used inside the compiler.
[...] That will *certainly* be a big bonus. It will open up the opportunity for many, many user-contributed tools for manipulating D code. Like pretty printers, class hierarchy navigators, code analyzers, VIM tags, and all sorts of über-cool stuff. T -- If Java had true garbage collection, most programs would delete themselves upon execution. -- Robert Sewell
Mar 12 2012
prev sibling parent Philippe Sigaud <philippe.sigaud gmail.com> writes:
Alix Pexton:

 Rainer Schuetze pulled all the grammar out of the docs and fixed them up
a while back as part of his work on Visual D. Its not in straight EBNF and it may not be 100% up to date, but it may be a good place to start.
 http://www.dsource.org/projects/visuald/wiki/GrammarComparison

 I hope that is of some use!
It is! Thanks Alix and thanks Rainer, the page is clean and readable. I'll use it at once. I admit reading the spec in detail for the first time yesterday, and I had a few WAT moments. No with the way it's written per se, but for what is seemingly allowed by the D grammar.
Mar 12 2012