Author Topic: I think these links helpful to redesign code completion plugin  (Read 22763 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
I think these links helpful to redesign code completion plugin
« on: February 09, 2009, 03:37:15 pm »
VCF builder, It seems the development stopped two years ago :(.

GCC XML 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 and Output Xml file

Stream-Based Parsing in C++ A general introduction article about parser a c++ file.

a simple c parser

parser at berkele








« Last Edit: February 09, 2009, 04:29:00 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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I think these links helpful to redesign code completion plugin
« Reply #1 on: February 23, 2009, 04:58:21 am »
I found a editor with support C++ parser.
http://code.google.com/p/ljedit/
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 alb_cb_moon

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: I think these links helpful to redesign code completion plugin
« Reply #2 on: March 10, 2009, 07:18:06 am »
I found others links that coudl help:

Parsing C++: 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 Meta Compilation for C++
Compilers and Compiler Generators text course of compilers using c++
YARD (Yet Another Recursive Descent Parser)
online papersEmbedded Input Parsing for C++
OS: Windows XP SP2
GUI Library: wxWidgets 2.8.10
IDE: CodeBlocks SVN / Nigth Builds Compiler: MinGW & gcc 3.4.5

Offline alb_cb_moon

  • Multiple posting newcomer
  • *
  • Posts: 25
Re: I think these links helpful to redesign code completion plugin
« Reply #3 on: March 17, 2009, 07:08:24 am »
I find another interesting link:

ANTLR & C++, PCCTS handbook
OS: Windows XP SP2
GUI Library: wxWidgets 2.8.10
IDE: CodeBlocks SVN / Nigth Builds Compiler: MinGW & gcc 3.4.5

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I think these links helpful to redesign code completion plugin
« Reply #4 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.
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 eranif

  • Regular
  • ***
  • Posts: 256
Re: I think these links helpful to redesign code completion plugin
« Reply #5 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


Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I think these links helpful to redesign code completion plugin
« Reply #6 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. :(
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 eranif

  • Regular
  • ***
  • Posts: 256
Re: I think these links helpful to redesign code completion plugin
« Reply #7 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

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I think these links helpful to redesign code completion plugin
« Reply #8 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
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I think these links helpful to redesign code completion plugin
« Reply #9 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. :(
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I think these links helpful to redesign code completion plugin
« Reply #10 on: November 06, 2010, 04:12:01 am »
link added
Hyperlinked C++ BNF Grammar

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...
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6025
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: I think these links helpful to redesign code completion plugin
« Reply #11 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

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.