Author Topic: CodeCompletion plugin  (Read 11024 times)

Offline ptDev

  • Almost regular
  • **
  • Posts: 222
Re: CodeCompletion plugin
« Reply #15 on: May 01, 2011, 05:19:10 pm »
Note that it is not necessary to distinguish between keywords and symbols at this stage yet. Doing this reduces the time spent later on comparing strings in the parser.
thanks for the reply.

BTW: I need to say some words about your idea.


So, it have a fixed keywords definition which can be defined in the lexer grammar. So, the lexer can distinguish a c++ keyword and a general identifier.
When it meets a keyword, it just return a type id (int value), and no text is needed, this can avoid the hashtable search stage.

From my point of view, this way should be more faster.

Searching a wxString in a std::map<wxString,int> would be pretty fast, yes.
And the least strings needed for semantical analysis, the better, of course :)
« Last Edit: May 01, 2011, 06:12:35 pm by ptDev »

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: CodeCompletion plugin
« Reply #16 on: May 01, 2011, 09:32:05 pm »
I recently did a custom-language parser done in javascript (to make some javascript templates). I came to the same conclusion: Replacing string tokens with token ids is much, much faster. As a former CC dev, I applaud this initiative :)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5324
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: CodeCompletion plugin
« Reply #17 on: May 03, 2011, 10:21:52 am »
Here is my code test:
void MyFunction(int paraA, float paramB)
    for(int index = 0; Foo* foofoo = Something.getFooByIndex(index); ++index)
       // let's do something with foofoo
       int i;
    //type + variable
    for(int a=0;a<10;a++)
       int i;
    for(NS::MyClass a=0;a<100;a++)
       int i;

    // type containing some template info
    for(MyNameSpace::MyTempLateClass<X,Y> a=0;a.DoSomething>b;a++)

    // pointer declaration
    for(int *a=0;a<0x4444;a = a+4)
    for(int **a=0;a<0x4444;a = a+4)

    // two variables
    for(int *a=0, b=0;...)

and here is the result:
function MyFunction 1:6
   for  3:5
      variable index 3:13
      variable foofoo 3:29
      variable i 7:12
   for  12:5
      variable a 12:13
      variable i 14:12
   for  18:5
      variable a 18:21
      variable i 20:12
   for  25:5
      variable a 25:43
   for  29:5
      variable a 29:14
   for  31:5
      variable a 31:15
   for  35:5
      variable a 35:14

the xxx:xxx showing a symbol position by line:column.

But I think my parser is still not mature. :D, it need a long time and long way to go :D
« Last Edit: May 03, 2011, 10:47:12 am 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.