BNF grammar for D?
Kingsley via Digitalmars-d
digitalmars-d at puremagic.com
Wed Dec 17 09:19:01 PST 2014
On Wednesday, 17 December 2014 at 12:31:32 UTC, Bruno Medeiros
wrote:
> On 17/12/2014 09:13, Kingsley wrote:
>> On Wednesday, 17 December 2014 at 03:03:59 UTC, Rikki
>> Cattermole wrote:
>>> On 17/12/2014 1:35 p.m., Kingsley wrote:
>>>> On Tuesday, 16 December 2014 at 23:25:02 UTC, Kingsley wrote:
>>>>> On Monday, 27 October 2014 at 22:40:20 UTC, landaire wrote:
>>>>>> 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.
>>>>>
>>>>> Hi guys,
>>>>>
>>>>> I have been working on an intellij plugin which is here:
>>>>> https://github.com/kingsleyh/DLanguage
>>>>>
>>>>> I only started learning D a couple of weeks ago and I
>>>>> haven't written
>>>>> an intellij plugin before - and also I'm not very familiar
>>>>> with
>>>>> parsing/lexing.
>>>>>
>>>>> On my first pass - I got all the infrastructure working -
>>>>> e.g. run
>>>>> configurations, project creation, file creation etc. And
>>>>> I'm working
>>>>> on a BNF and JFlex by hand - but I realise it will take
>>>>> some time - so
>>>>> I have a branch which implements the DDT parser/lexer so I
>>>>> could get
>>>>> something working while I work on the bnf - however it
>>>>> breaks the
>>>>> contextual run configurations - which is pretty much
>>>>> essential for the
>>>>> plugin to be useful.
>>>>>
>>>>> I'd like to get the DDT parser/lexer working but I'm not
>>>>> really sure
>>>>> where to go from where I am now. My DDT branch is called
>>>>> with_ddt.
>>>>>
>>>>> If anyone has any pointers to what I need to do next that
>>>>> would be
>>>>> very helpful - even in terms of reading or reference
>>>>> material. I guess
>>>>> it all comes down to the DParserDefinition class - as my
>>>>> master branch
>>>>> uses a FlexAdapter which gives access to the context. But
>>>>> in the
>>>>> with_ddt branch its just using the DParser - which I think
>>>>> needs to
>>>>> have the hooks into the AST tree implemented or something
>>>>> like that.
>>>>>
>>>>> Anyway let me know if you have any pointers or offers of
>>>>> help :)
>>>>>
>>>>> --K
>>>>
>>>> Actually I guess what I need is a way to make the PSI
>>>> structure. I'm not
>>>> sure how I would do that with the DDT code I have imported.
>>>
>>> I've sent you an email reguarding my own work on getting a
>>> plugin
>>> together using Dscanner. As well as the source code.
>>> Feel free to use it.
>>
>> I've successfully integrated the Psi generation stuff with the
>> DDT
>> parser/lexer now with a huge thanks to Rikki. So now I think I
>> can add
>> all the other ps related stuff - code insight, refactoring,
>> completion
>> etc etc
>>
>> Of course its the first cut - so I'll have to do some code
>> cleanup once
>> I understand what I'm doing!
>>
>> Thanks for your help and support :)
>
> Also, if you have questions about the DDT parser/lexer, or if
> there are changes that might help your project, let me know,
> I'll be glad to add such changes (assuming they also fit well
> with the way DDT uses the parser/lexer).
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
More information about the Digitalmars-d
mailing list