General code completion framework written in C/C++ - c++

Is there any framework written in C/C++/C++11 for writing code completion tools?
Or maybe are there some libraries that allow code completion for Java or C++ (also written in C++?).
I'm writing my custom IDE in C++ for Java (and not only Java) development and I want to add code completion support to it the best possible way, without reinventing the weel ;)

clang_complete is a plugin for vim for accurately completing C, C++, Objective-C and Objective-C++ code: https://github.com/Rip-Rip/clang_complete/
It uses clang - an open source C++ compiler written in C++ for doing the job. I guess you may find it useful.

Related

How can I parse C++ code in a prebuild event?

I have a prebuild-event tool (written in Ruby) in my C++ toolchain, that generates additional C++ code from existing C++ source code. I would like to replace this tool with a faster generator and using clang would be the best option.
Is there a way to write a C++ application that parses C++ source code of a file, so I can implement this prebuild tool in Clang? I am looking for a keyword or page with how to start. Any help is highly appreciated!
Parsing C++ is not a simple thing. Compile-time trickery and implicit semantics make it incredibly hard. Because of this I would suggest going with Clang. Its developers made it possible to use Clang as a library. Check out this guide to see different interfaces Clang has. If you want real C++ experience you might want to choose LibTooling.
I want to warn you though that in order for any C/C++ parser to work as expected they absolutely need compilation options used by the real compiler. Without include directories or macro definitions the code can make little to no sense. Basically your build system should tell your custom tool how to compile each file. The simplest approach would be using compilation database. It is a go-to solution for many Clang-based tools. However, it looks like you're making it a part of your build system, so maybe incorporating your tool and using options directly from the build system can be not such of a burden for you.
I hope this information is helpful!

Antlr c++ target sample

I am new to antlr.
Can somebody provide a working example for any simple grammar in antlr for C++ target. I tried antlrworks and created the lexer and parser. But am not able to proceed while getting it compiled. Searched in codeproject also for a working sample, but dint find any.
I am planning to use Visual Studio 2013. Thanks in advance...
I've used ANTLR3 in a C++ application for years already, but actually used the C target, not C++. The latter proved to be a problem both in terms of compilation speed (for a highly complex parser) and complexity (all based on templates). So I settled on the C target, which is easy to integrate into C++ application. You only need a small C++ wrapper for your app and you will get a really fast parser.
In case of C++ target try this branch: https://github.com/ibre5041/antlr3/tree/master/runtime/Cpp/tests. This is more up to date version, including various performance bug fixes, memory leak fixes and also AST generation.
In the tests directory you find some examples.
Now I'm not sure whether it will work with MSVC 2013, I recall I used some C++11.
It would be best if you compiled the whole tool from these sources, not only the runtime is different, but also generated source codes slightly differ.
No not use Java 8 to compile and run antlr tool. For some mysterious reason JRE8 generates different sources then JRE7, when using the same tool .jar.
When having your grammar compiled (sources are generated), then you have to create, a traits class to be used as "configuration" for generated sources.

Combining Objective-C and C/C++ on Mac OS X

Can I create an Objective-C library (by XCode) and use it in my C/C++ application (compiled by GCC without supporting Objective-C).
You need to create a C or C++ interface for your Objective-C code, so you can use this interface to call the Objective-C code from your C/C++ code. Note that you can take advantage of Cocoa's toll-free bridging: e.g. you can return an NSString* and interpret it as a CFStringRef in your C/C++ code.
You can try this tool (it's fairly raw at the moment) to generate C/C++ bindings for Objective-C code (created to help get Wine [C only] code working with OSX[Objective-C] libraries).
This email explains how the tool came about and has the binding generating code as an attachment.
http://www.winehq.org/pipermail/wine-devel/2011-April/089657.html
The download is actually a tar.gz.
You could give it a shot yourself and then try emailing Charles about using it if it's too much trouble (and bug him to set it up as a proper project somewhere. :-)

Embedding Mono vs Google V8?

We want to add scripting to a project.
We are hesitating which script engine to use.
I have used in the past V8 and it's quite impressive. I have used Mono as well but in toy-projects or prototypes only.
The constraints are :
speed of execution.
easy integration.
must work on windows.
64-bit support.
compiles under Visual Studio.
Which engine fits the best ?
(Are there any tutorial for compiling Mono under win64 with Visual Studio?
Is there some packages that include Lib files and DLLs ?)
I would suggest you to take a look at Lua. I think it fits your needs quite satisfactorily.
Since there are no upvoted answers, I'm going to mention ChaiScript (Yes, I'm a co-creator of the project). It's a header only scripting engine designed solely for embedding in C++ applications. It has full 64bit support and works with MSVC, G++ and MinGW. The only external dependency is boost.
Where it does not win is speed. If you need to do a lot of calculation in the script itself, well, I argue that you are using scripting wrong. The higher level the function you can expose to the scripting engine, the better.
V8. It actually is a scripting engine rather than a full programming environment like Mono (which rivals Java for size).
However... if you want a scripting language, you might also want to have a look at Lua. It's famously easy to embed, really fast, really small, pretty easy to program for, and has a very liberal license. If speed's important there's LuaJIT, which is still under development but with care will handily beat C for numerical programming.
There is an MSVS solution file included into Mono distribution, it is enough for building a library (but you won't be able to build .DLLs, better pick them from a binary distribution). See mkbundle for a way to embed .NET DLLs into a single binary. As for scripting itself, you can either embed Mono C# compiler (it is not that big, and it is easy to integrate) or use any of the numerous scripting languages that target .NET - e.g., IronPython.
Python isn't bad either, with Boost.Python.

C++ Reads/Writes XML without CLR

I know this is a very stupid question and I'm very new to C++.
I'm developing Starcraft AI, it is DLL file. I'm trying to use XML to gather some data to the bot, however whenever I build the DLL with /clr option. The bot doesn't load properly. So, my question is what is CLR and is there a way to read/write XML without using /clr build option.
Thanks so much.
The /clr compiler option enables the
use of Managed Extensions for C++ and
creates an output file that will
require the .NET Framework common
language runtime at run time.
(from MSDN)
Starcraft is probably not developed under CLR (.NET Framework runtime).
I've used the free tinyxml library from C++ code - it was quick to get running and reasonably efficient. Well, about as efficient as it's possible for XML to be, anyway.
Starcraft probably won't run .NET binaries. You would have to either write your own XML parser, which probably isn't for you seeing as you are new to C++, or find a C++ library that can do it for you.
Example of one:
http://sourceforge.net/projects/tinyxml/