Author Topic: variable seperated by commas  (Read 8677 times)

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6035
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
variable seperated by commas
« on: December 21, 2009, 10:54:05 am »
For example:
Code
int *a,b;

In the current CodeCompletion symbol browser, there are two Tokens found.

Code
a, its type is int*
b, its type is int*

I think it is wrong, because the correct Token should be

Code
a, it's type is int*
b, it's type is int

In the code:
wxString ParserThread::GetActualTokenType()

it seems the "*" is binding to the left. So, if you define a variable like below:

Code
const wxString * AAAA;

AAAA is firstly regarded as a Token name.

Then we will analysis the const wxString * .

The currently CC didn't parser the pointer list definition well.
This also happens in handling typedefs.
Also, you can see the code in:
Code
void ParserThread::HandleTypedef()
{
  

    size_t lineNr = m_Tokenizer.GetLineNumber();
    bool is_function_pointer = false;
    wxString typ;
    std::queue<wxString> components;
    // get everything on the same line

    TRACE(_T("HandleTypedef() : Typedef start"));
    wxString args;
    wxString token;
    wxString peek;
    m_ParsingTypedef = true;

    while (true)
    {
        token = m_Tokenizer.GetToken();
        peek = m_Tokenizer.PeekToken();
        TRACE(_T("HandleTypedef() : token=%s, peek=%s"), token.wx_str(), peek.wx_str());
        if (token.IsEmpty() || token == ParserConsts::semicolon)
            break;

We only take care of the "semicolon", but how can we deal with commas

« Last Edit: December 21, 2009, 10:56:59 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.

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: variable seperated by commas
« Reply #1 on: December 22, 2009, 06:20:25 am »
also these test codes don't work .

Code
#include <iostream>

using namespace std;
typedef class qq
{
    int x;
    int y;
}*pp;

int main()
{
    cout << "Hello world!" << endl;
    return 0;
}

see the screen shot.

[attachment deleted by admin]
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?

Offline blueshake

  • Regular
  • ***
  • Posts: 458
Re: variable seperated by commas
« Reply #2 on: December 25, 2009, 11:41:58 am »
not work for these codes ethier.

Code
#include <iostream>

using namespace std;
class qq
{
    int x;
    int y;
}tt,*pp;
int main()
{
    cout << "Hello world!" << endl;
    return 0;
}
Keep low and hear the sadness of little dog.
I fall in love with a girl,but I don't dare to tell her.What should I do?