News:

Accounts with zero posts and zero activity during the last months will be deleted periodically to fight SPAM!

Main Menu

CodeCompletion plugin

Started by killerbot, April 20, 2011, 03:52:15 PM

Previous topic - Next topic

ptDev

#15
Quote from: ollydbg on May 01, 2011, 05:10:16 PM
QuoteNote 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 :)

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

#17
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
      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;...)
;
}


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