Jump to page: 1 24  
Page
Thread overview
BNF grammar for D?
Oct 27, 2014
landaire
Oct 27, 2014
Brian Schott
Oct 27, 2014
landaire
Oct 27, 2014
Jeremy Powers
Oct 27, 2014
landaire
Oct 27, 2014
Jeremy Powers
Oct 31, 2014
Bruno Medeiros
Oct 27, 2014
Jeremy Powers
Oct 27, 2014
landaire
Dec 16, 2014
Kingsley
Dec 17, 2014
Kingsley
Dec 17, 2014
Rikki Cattermole
Dec 17, 2014
Kingsley
Dec 17, 2014
Bruno Medeiros
Dec 17, 2014
Kingsley
Dec 17, 2014
Kingsley
Dec 18, 2014
Kingsley
Dec 19, 2014
Rikki Cattermole
Dec 21, 2014
Kingsley
Dec 22, 2014
Kingsley
Jan 08, 2015
Bruno Medeiros
Jan 08, 2015
Bruno Medeiros
Jan 08, 2015
Bruno Medeiros
Oct 31, 2014
Bruno Medeiros
Oct 31, 2014
Rikki Cattermole
Nov 07, 2014
Bruno Medeiros
Nov 08, 2014
Rikki Cattermole
Oct 27, 2014
Rikki Cattermole
Oct 27, 2014
landaire
Oct 28, 2014
Rikki Cattermole
Oct 27, 2014
Brian Schott
Oct 28, 2014
Rikki Cattermole
Oct 31, 2014
Bruno Medeiros
Oct 31, 2014
Daniel Kozák
Nov 07, 2014
Bruno Medeiros
October 27, 2014
There have been similar questions asked on this forum before (most recent one in June with no result: http://forum.dlang.org/thread/CAFMGiz8Fyv2A+ScQPQtEYEsFSybZNfY--nsxL5rqNoWWNA4agg@mail.gmail.com?page=1), but I was curious if anyone happens to have a BNF grammar for D laying around. I've searched all over and can't seem to find anything.

I'm trying to make a plugin for IntelliJ IDEA to support D (https://github.com/landaire/intelliD is what I have now utilizing DDT's lexer) but a lot of what's required to add advanced features like code folding, code completion, etc. is generally autogenerated by JetBrains's Grammar Kit plugin which only generates that stuff from a BNF grammar.

I know nothing about writing language grammars but based off what I've seen it doesn't look like it'd be *too* difficult to pick up, so if anyone also has suggestions for good readings I'd appreciate that as well.
October 27, 2014
On Monday, 27 October 2014 at 22:06:28 UTC, landaire wrote:
> I've searched all over and can't seem to find anything.

There are links to my projects in that thread. https://github.com/Hackerpilot/libdparse should help. The doc comments for the parser tell you the grammar that they implement. (The DGrammar project is based on these ddoc comments. This reminds me that I need to update it.) The official language spec on http://dlang.org/grammar.html has been getting better recently. You may want to look at that as well.

> I'm trying to make a plugin for IntelliJ IDEA to support D (https://github.com/landaire/intelliD is what I have now utilizing DDT's lexer) but a lot of what's required to add advanced features like code folding, code completion, etc. is generally autogenerated by JetBrains's Grammar Kit plugin which only generates that stuff from a BNF grammar.

Beware that D's grammar is ambiguous in several places.

October 27, 2014
This looks eerily familiar...

I took a stab at an Intellij plugin a long time ago, and happened to pick the same name:

https://github.com/elendel-/intelliD

Been meaning to pick back up again, but haven't had the chance... was waiting for the Eclipse plugin code to mature, then got distracted.  Feel free to take anything that looks useful.


Brian Schott (Hackerpilot) has done a lot of useful work grammar wise.  See:

https://github.com/Hackerpilot/DGrammar

An interesting path to take for an intellij plugin would be to use his DCD/libdparse for all the heavy lifting, with the plugin just farming out the work to external daemon process(es).  That would avoid having yet another lexer/parser implementation to keep up to date.




On Mon, Oct 27, 2014 at 3:06 PM, landaire via Digitalmars-d < digitalmars-d@puremagic.com> wrote:

> There have been similar questions asked on this forum before (most recent one in June with no result: http://forum.dlang.org/thread/CAFMGiz8Fyv2A+ ScQPQtEYEsFSybZNfY--nsxL5rqNoWWNA4agg@mail.gmail.com?page=1), but I was curious if anyone happens to have a BNF grammar for D laying around. I've searched all over and can't seem to find anything.
>
> I'm trying to make a plugin for IntelliJ IDEA to support D ( https://github.com/landaire/intelliD is what I have now utilizing DDT's lexer) but a lot of what's required to add advanced features like code folding, code completion, etc. is generally autogenerated by JetBrains's Grammar Kit plugin which only generates that stuff from a BNF grammar.
>
> I know nothing about writing language grammars but based off what I've seen it doesn't look like it'd be *too* difficult to pick up, so if anyone also has suggestions for good readings I'd appreciate that as well.
>


October 27, 2014
On Monday, 27 October 2014 at 22:30:15 UTC, Brian Schott wrote:
> On Monday, 27 October 2014 at 22:06:28 UTC, landaire wrote:
>> I've searched all over and can't seem to find anything.
>
> There are links to my projects in that thread.

Sorry, what I meant was I couldn't find a BNF grammar :)

I must have overlooked libdparse but I did find  https://github.com/Hackerpilot/DGrammar which helped quite a bit! But cool, thanks for mentioning the grammar comments.

I was more or less hoping I wouldn't have to redo a bunch of the work that someone's already done for me by writing the grammar. Even if I do have to do it from scratch it should be a good learning experience.

> Beware that D's grammar is ambiguous in several places.

Do you have any specific examples off the top of your head?
October 27, 2014
On Monday, 27 October 2014 at 22:35:16 UTC, Jeremy Powers via Digitalmars-d wrote:
> This looks eerily familiar...
>
> I took a stab at an Intellij plugin a long time ago, and happened to pick
> the same name:
>
> https://github.com/elendel-/intelliD
>
> Been meaning to pick back up again, but haven't had the chance... was
> waiting for the Eclipse plugin code to mature, then got distracted.  Feel
> free to take anything that looks useful.
>
>
> Brian Schott (Hackerpilot) has done a lot of useful work grammar wise.  See:
>
> https://github.com/Hackerpilot/DGrammar
>
> An interesting path to take for an intellij plugin would be to use his
> DCD/libdparse for all the heavy lifting, with the plugin just farming out
> the work to external daemon process(es).  That would avoid having yet
> another lexer/parser implementation to keep up to date.
>

I actually forked yours originally to get it running in IDEA 14, then decided to mess with the lexer since it was causing some problems and went off from there. I saw it was somewhat inactive and tried contacting you, but couldn't find any of your contact info anywhere! Glad to see you turned up here.
October 27, 2014
>
> There are links to my projects in that thread. https://github.com/ Hackerpilot/libdparse should help. The doc comments for the parser tell you the grammar that they implement. (The DGrammar project is based on these ddoc comments. This reminds me that I need to update it.) The official language spec on http://dlang.org/grammar.html has been getting better recently. You may want to look at that as well.
>
>
Not only was I ninja'd by the actual expert, just realized your project is explicitly based on mine... go look at Brian's stuff, it's much better than mine.

>From my mucking about before, I think you'll get more mileage from using
libdparse directly than trying to (re)implement a parser for the plugin. For one, you save yourself all the pain of fixing weird edge cases and keeping up to date.


October 27, 2014
On Monday, 27 October 2014 at 22:43:55 UTC, Jeremy Powers via Digitalmars-d wrote:
>
>From my mucking about before, I think you'll get more mileage from using
> libdparse directly than trying to (re)implement a parser for the plugin.
> For one, you save yourself all the pain of fixing weird edge cases and
> keeping up to date.

I agree, but integrating something external with IntelliJ's platform seems like kind of a PITA. It looks like a lot of stuff makes heavy use of PSI trees (see: https://confluence.jetbrains.com/display/IDEADEV/Developing+Custom+Language+Plugins+for+IntelliJ+IDEA#DevelopingCustomLanguagePluginsforIntelliJIDEA-ImplementingaParserandPSI)

I'm no expert in developing IntelliJ plugins either though...
October 27, 2014
> Glad to see you turned up here.

I'm usually lurking around...


> I agree, but integrating something external with IntelliJ's platform seems like kind of a PITA. It looks like a lot of stuff makes heavy use of PSI trees (see: https://confluence.jetbrains.com/display/IDEADEV/ Developing+Custom+Language+Plugins+for+IntelliJ+IDEA# DevelopingCustomLanguagePluginsforIntelliJIDEA-ImplementingaParserandPSI)
>
> I'm no expert in developing IntelliJ plugins either though...
>

The totally-not-thought-out idea I had was to have the IntelliJ tree map to the results of libdparse.  So each AST (or PSI) call is just a front for the info provided by libdparse (with caching etc).  Then all the work shifts away from writing a parser to writing the hairy integration bits.


October 27, 2014
On Monday, 27 October 2014 at 22:06:28 UTC, landaire wrote:
> There have been similar questions asked on this forum before (most recent one in June with no result: http://forum.dlang.org/thread/CAFMGiz8Fyv2A+ScQPQtEYEsFSybZNfY--nsxL5rqNoWWNA4agg@mail.gmail.com?page=1), but I was curious if anyone happens to have a BNF grammar for D laying around. I've searched all over and can't seem to find anything.
>
> I'm trying to make a plugin for IntelliJ IDEA to support D (https://github.com/landaire/intelliD is what I have now utilizing DDT's lexer) but a lot of what's required to add advanced features like code folding, code completion, etc. is generally autogenerated by JetBrains's Grammar Kit plugin which only generates that stuff from a BNF grammar.
>
> I know nothing about writing language grammars but based off what I've seen it doesn't look like it'd be *too* difficult to pick up, so if anyone also has suggestions for good readings I'd appreciate that as well.

I've also been playing with getting a Intellij IDEA plugin up but it utilises DScanner. The only issue I'm having right now is for some reason its adding two elements to the Psi's tree instead of just one. Where the second has correct data but first is the correct type.
Not to mention getting dscanner to output the correct line number/index ext. Fun times.
October 27, 2014
On Monday, 27 October 2014 at 23:17:14 UTC, Rikki Cattermole wrote:
> On Monday, 27 October 2014 at 22:06:28 UTC, landaire wrote:
> I've also been playing with getting a Intellij IDEA plugin up but it utilises DScanner. The only issue I'm having right now is for some reason its adding two elements to the Psi's tree instead of just one. Where the second has correct data but first is the correct type.
> Not to mention getting dscanner to output the correct line number/index ext. Fun times.

Is your work published on GitHub or elsewhere? I'd like to take a look at your approach.
« First   ‹ Prev
1 2 3 4