BNF grammar for D?

Rikki Cattermole via Digitalmars-d digitalmars-d at puremagic.com
Thu Dec 18 18:52:58 PST 2014


On 19/12/2014 10:19 a.m., Kingsley wrote:
> On Wednesday, 17 December 2014 at 21:05:05 UTC, Kingsley wrote:
>>
>>> Hi Bruno,
>>>
>>> Thanks very much. I do have a couple of questions about DDT in
>>> relation to my plugin.
>>>
>>> Firstly - I'm not too familiar with parsing/lexing but at the moment
>>> the Psi Structure I have implemented that comes from the DDT
>>> parser/lexer is not in any kind of hierarchy. All the PsiElements are
>>> available but all at the same level. Is this how the DDT parser
>>> works? Or is it down to my implementation of the Parser/Lexer that
>>> wraps it to create some hierarchy.
>>>
>>> For intellij it's going to be vastly easier to have a hierarchy with
>>> nested elements in order to get hold of a structure representing a
>>> class or a function for example - in order to do things like get the
>>> start and end lines of a class definition in order to apply code
>>> folding and to use for searching for classes and stuff.
>>>
>>> Secondly - how active it the development of DDT - does it keep up
>>> with the D2 releases.
>>>
>>> --Kingsley
>>
>> After doing a bit more research it looks like I have to create the psi
>> hierarchy myself - my current psi structure is flat because I'm just
>> converting the DeeTokens into PsiElements directly. I've still got
>> some experimentation to do. On the plus side I implemented commenting,
>> code folding but everything else needs a psi hierarchy
>
> I've done some more investigation and I do need to build the parser
> myself in order to create the various constructs. I've made a start but
> I haven't gotten very far yet because I don't fully understand the
> correct way to proceed.
>
> I also had a look at using the DeeParser - because it already does most
> of what I want. However the intellij plugin wants a PsiParser which
> returns an intellij ASTNode in the primary parse method. I can't see an
> easy way to hook this up with DeeParser because the ParsedResult
> although had a node method on it - gives back the wrong type of ASTNode.
>
> Any pointers on how I might get the DeeParser to interface to an
> intellij ASTNode would be appreciated.

Read my codebase again, it'll answer a lot of questions. Your parser is 
different, but what it produces shouldn't be. and yes it supports 
hierarchies.


More information about the Digitalmars-d mailing list