Developer forums (C::B DEVELOPMENT STRICTLY!) > Plugins development

CodeCompletion plugin

<< < (4/4)

ptDev:

--- Quote from: ollydbg on May 01, 2011, 05:10:16 pm ---
--- Quote ---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.
--- End quote ---
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.

--- End quote ---

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 :)

rickg22:
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 :)

ollydbg:
Here is my code test:

--- Code: ---void MyFunction(int paraA, float paramB)
{
    for(int index = 0; Foo* foofoo = Something.getFooByIndex(index); ++index)
    {
       // let's do something with foofoo
       foofoo->DoSomething();
       int i;
       i++;
    }
    
    //type + variable
    for(int a=0;a<10;a++)
    {
       int i;
       i++;
    };
    
    for(NS::MyClass a=0;a<100;a++)
    {
       int i;
       i++;
    };

    // type containing some template info
    for(MyNameSpace::MyTempLateClass<X,Y> a=0;a.DoSomething>b;a++)
        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;...)
;
}

--- End code ---

and here is the result:

--- Code: ---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


--- End code ---
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

Navigation

[0] Message Index

[*] Previous page

Go to full version