Author Topic: Plugin for multi-language support: a proposal  (Read 7206 times)

Offline ltcmelo

  • Single posting newcomer
  • *
  • Posts: 3
Plugin for multi-language support: a proposal
« on: September 29, 2015, 03:10:21 pm »
Hi everyone,

does Code::Blocks intend to (eventually) support additional programming languages? If so, I'd like to make a proposal.

I've been working on a multi-language code modelling engine. It comes with its own lightweight parsers which construct a language-unifying AST, on top of which a pipeline of symbol binding, type checking, code completion, etc. is provided. Along the way, hooks are available for languages to define specific behavior. The entire engine is pure C++ and agnostic of a particular IDE or text editor.

The project is incipient but already working. In the following videos you can have glimpse of it for the Go and D programming languages (I recently started working on Python): https://youtu.be/nUpcVBAw0DM and https://youtu.be/ZwMQ_GB-Zv0 . This is a prototype "deployment" on the Qt Creator IDE.

Would anyone be interested on building a Code::Blocks plugin for this engine? I'd be willing to collaborate on the engine side, to collect feedback on what's working and what's not, to adjust the design if needed, to prioritize certain features, and so on.

If you want to take a look around: https://github.com/ltcmelo/uaiso


Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5907
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Plugin for multi-language support: a proposal
« Reply #1 on: September 29, 2015, 03:47:05 pm »
Looked at the Youtube video, it looks great! Good job!

Are you going to support the C/C++ parser in the model? Our native implementation of C/C++ parser are not quite good at handling template related code.

We have a general code completion framework in our SDK, so it is not quite difficult for other languages, we already have Fortran, C/C++, Python code completion support.

EDIT:
It looks like you are a maintainer of the cplusplus model in QTcreator from 2010 to 2012, and I see that this cplusplus model is still maintained by some contributor, but I also see QTcreator will use Clang as it's language model.




« Last Edit: September 29, 2015, 04:48:39 pm by ollydbg »
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ltcmelo

  • Single posting newcomer
  • *
  • Posts: 3
Re: Plugin for multi-language support: a proposal
« Reply #2 on: September 30, 2015, 03:48:32 am »
Thanks for the appreciation ;-)

I intent to introduce C and C++ into the model as well, but it's not my priority. In fact, one alternative would be to start off from Qt Creator's C++ parser, but since it has certain limitations with templates as well, it's questionable how much it would improve on Code::Block's, at least during initial stage. If my project gets some traction I'd of course invest on it (I'm currently developing it on my spare time).

I didn't know you already had Python support, that's good. Nevertheless, I'm open to integrate other languages too. For instance, I'm studying Rust right now. Therefore, if you believe there's a front in which we can collaborate, please let me know.

I never checked Code::Block's source, but I'm curious about your general code completion framework. I guess I should take a look into it.

Regarding Qt Creator's clang-based code model, it's there but I don't how much people are working on it. I participated in the early development phase when we were experimenting things around. Back then, the primary issue we had was performance. Qt Creator's native C++ parser is slick because it does some "tricks" that are not standard conformant but work pretty well in most code bases. Clang, on the other hand, is a real compiler so this was kind of expected.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5907
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Plugin for multi-language support: a proposal
« Reply #3 on: October 05, 2015, 05:06:26 am »
Thanks for the appreciation ;-)

I intent to introduce C and C++ into the model as well, but it's not my priority. In fact, one alternative would be to start off from Qt Creator's C++ parser, but since it has certain limitations with templates as well, it's questionable how much it would improve on Code::Block's, at least during initial stage. If my project gets some traction I'd of course invest on it (I'm currently developing it on my spare time).
As I know, QT Creator's C++ parser(the same parser in Kdeveloper IDE) has many QT related code in it, so it is not easy to integrate to C::B or other non-QT related IDE. From my point of view, the native c++ parser is better than the one in our C::B's code base. Of cause, both are not good enough compared with the real compiler Clang.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline ltcmelo

  • Single posting newcomer
  • *
  • Posts: 3
Re: Plugin for multi-language support: a proposal
« Reply #4 on: October 05, 2015, 11:18:48 pm »
That's not quite true ollydbg.

Qt Creator's C++ parser itself is plain C++, there's no dependency on Qt at all: https://github.com/qtproject/qt-creator/tree/master/src/libs/3rdparty/cplusplus (it also has its own license). What has lots of Qt code is the modelling engine and subsequent features of the IDE.

It's true that both Qt Creator's and KDevelop's original parser is the same. But it's been probably a decade since they diverged. Nowadays, I'd not be surprised if they don't share a line of code. ;-)

That being said, what I could suggest is that you take a look at the link above and check whether or not that parser would significantly improve on C::B's one. If that's the case, I could perhaps change my priority list and integrate it into my project.






 

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5907
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: Plugin for multi-language support: a proposal
« Reply #5 on: October 06, 2015, 01:17:47 am »
That's not quite true ollydbg.

Qt Creator's C++ parser itself is plain C++, there's no dependency on Qt at all: https://github.com/qtproject/qt-creator/tree/master/src/libs/3rdparty/cplusplus (it also has its own license). What has lots of Qt code is the modelling engine and subsequent features of the IDE.

Thanks. I remember several years ago, I have looked at its preprocessor related code, and it was located in
qt-creator/src/libs/cplusplus at master ยท qtproject/qt-creator, and I see it has a lot of QT related code. I'm not sure what's the relation ship between "libs/3rdparty/cplusplus" and "libs/cplusplus".

Quote
It's true that both Qt Creator's and KDevelop's original parser is the same. But it's been probably a decade since they diverged. Nowadays, I'd not be surprised if they don't share a line of code. ;-)

That being said, what I could suggest is that you take a look at the link above and check whether or not that parser would significantly improve on C::B's one. If that's the case, I could perhaps change my priority list and integrate it into my project.
I believe its parser it better than C::B's, but I don't know how easy we can integrate this. :)
In C::B, we have some kinds of :low level parser: such as Tokenizer with preprocessor, Parser, TokenTree(a Trie Tree structure), some high level: like codecompletion, and other CC UIs like toolbar, symbol browser tree.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.