Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: ollydbg on February 09, 2009, 03:37:15 pm

Title: I think these links helpful to redesign code completion plugin
Post by: ollydbg on February 09, 2009, 03:37:15 pm
VCF builder (http://vcfbuilder.org/), It seems the development stopped two years ago :(.

GCC XML (http://www.gccxml.org) It use gcc as a internal parser, the current version is 0.9, can be download from sourceforge. But it seems template is not supported. examples are here: C code (http://www.gccxml.org/HTML/example1in.html) and Output Xml file (http://www.gccxml.org/HTML/example1out.html)

Stream-Based Parsing in C++ (http://accu.org/index.php/journals/346) A general introduction article about parser a c++ file.

a simple c parser (http://www.codeguru.com/cpp/cpp/cpp_mfc/parsing/article.php/c4069)

parser at berkele (http://www.cs.berkeley.edu/~smcpeak/elkhound/)








Title: Re: I think these links helpful to redesign code completion plugin
Post by: ollydbg on February 23, 2009, 04:58:21 am
I found a editor with support C++ parser.
http://code.google.com/p/ljedit/
Title: Re: I think these links helpful to redesign code completion plugin
Post by: alb_cb_moon on March 10, 2009, 07:18:06 am
I found others links that coudl help:

Parsing C++ (http://www.nobugs.org/developer/parsingcpp/index.html): Maybe old, but interesting point of view: build a C++ parser is a task so though that the autor give up, had useful links
Fog thesis (http://www.computing.surrey.ac.uk/research/dsrg/fog/FogThesis.html) Meta Compilation for C++
 Compilers and Compiler Generators (http://scifac.ru.ac.za/compilers/) text course of compilers using c++
 YARD (Yet Another Recursive Descent Parser) (http://www.ootl.org/yard/)
online papers (http://www.csse.monash.edu.au/~damian/papers/)Embedded Input Parsing for C++
Title: Re: I think these links helpful to redesign code completion plugin
Post by: alb_cb_moon on March 17, 2009, 07:08:24 am
I find another interesting link:

 ANTLR & C++, PCCTS handbook (http://www.inf.u-szeged.hu/~gertom/Oktatas/Anyag/fordprog-en.php)
Title: Re: I think these links helpful to redesign code completion plugin
Post by: ollydbg on March 17, 2009, 07:25:19 am
@alb_cb_moon:
All the links are very interesting. I have a glance at codeLite's parser, it use a lex and yacc grammar. But I'm just concerning it's performance. (It use CTags to generate a database).The current design in  CC parses all the files in the current workspace as soon as it was opened.
Title: Re: I think these links helpful to redesign code completion plugin
Post by: eranif on March 17, 2009, 02:36:03 pm
I have a glance at codeLite's parser, it use a lex and yacc grammar. But I'm just concerning it's performance. (It use CTags to generate a database).The current design in  CC parses all the files in the current workspace as soon as it was opened.

1) codelite uses codelite_indexer which is an executable that uses ctags as library and provide indexing services to codelite over Unix sockets (*Nix) / Named Pipes (Windows)
2) the lex & yacc are PARTIAL grammars and they cannot parse an entire file, they are using the lookup table generated by the indexer
3) CodeLite will index workspace on startup only if this option is enabled (by default it is turned off) and subject to the next bullet:
4) indexing is smart: only modified files are being re tagged and constantly re tagged upon file saving (i.e. attempting to right click on the workspace and selecting 'retag workspace' will only trigger one retagg, for the second retag you get message in the status bar that says "All files are up to date"

Eran

Title: Re: I think these links helpful to redesign code completion plugin
Post by: ollydbg on March 17, 2009, 03:46:39 pm
@eranif
Thanks for your explanation.
So, the MAIN parser is a index service (which is based on Ctag's parser), the Lex&Yacc is used to  parse the "lookup table generated by the indexer".

I had thought that you use Lex&Yacc to build a parser to parse the source file directly. :(
Title: Re: I think these links helpful to redesign code completion plugin
Post by: eranif on March 17, 2009, 04:19:20 pm
So, the MAIN parser is a index service (which is based on Ctag's parser), the Lex&Yacc is used to  parse the "lookup table generated by the indexer".

No, the indexer creates a database of tags collected from the entire workspace. It searches for declarations and implementations of:
- classes (include methods and variables)
- methods
- globals
- statics
- defines
- structs
- namespaces
- enums
- unions

The Yacc / Lex are used to resolve expressions:
GetManager()->GetWxString(). // completion here is resolved by the yacc grammar (and additional code)

Eran
Title: Re: I think these links helpful to redesign code completion plugin
Post by: ollydbg on March 17, 2009, 04:39:22 pm
So, the MAIN parser is a index service (which is based on Ctag's parser), the Lex&Yacc is used to  parse the "lookup table generated by the indexer".

No, the indexer creates a database of tags collected from the entire workspace. It searches for declarations and implementations of:
- classes (include methods and variables)
- methods
- globals
- statics
- defines
- structs
- namespaces
- enums
- unions

The Yacc / Lex are used to resolve expressions:
GetManager()->GetWxString(). // completion here is resolved by the yacc grammar (and additional code)

Eran
Ok, Thanks!
I understand now. It is a good idea to use Yacc&lex grammar to parse the context expression to give a correct tips. :D
Title: Re: I think these links helpful to redesign code completion plugin
Post by: ollydbg on June 26, 2009, 06:09:59 pm
Here is another one we can use for CC

http://qt.gitorious.org/qt-creator/qt-creator/trees/master

I have read it's source code, find that they use some code from "Kdevelop". You can see

QTcreator\src\libs\cplusplus\pp-engine.cpp

 :D

But these code were too complex to understand. :(
Title: Re: I think these links helpful to redesign code completion plugin
Post by: ollydbg on November 06, 2010, 04:12:01 am
link added
Hyperlinked C++ BNF Grammar (http://www.nongnu.org/hcb/#basic.link)

But to my knowledge, parsing C++ grammar is tooooo complex. :(

BTW: it seems the C++ 0x add many new C++ grammars, so our cc's heuristic parser should adjust a lot...
Title: Re: I think these links helpful to redesign code completion plugin
Post by: ollydbg on November 09, 2010, 03:56:02 am
added:

a c++ yacc/lex grammar implementation:

http://code.google.com/p/lbcplp/

quite complex though. :D