Developer forums (C::B DEVELOPMENT STRICTLY!) > CodeCompletion redesign

Check macro usage on every identifier like token: issues and discussions

<< < (8/8)

ollydbg:

--- Quote ---CC: [huki] parser - fixed handling of assignment within for loop.
--- End quote ---
I'm OK with this commit.
With this patch, we can handle the pattern:

--- Code: ---for(int i = 0; ...; ...)...

--- End code ---
And correctly recognize "i" as a variable.
I will commit soon. This is an enhancement on the original patch, see revision 8700, and the related patch page: Patch 3345 - Code::Blocks History

But I see in the function void ParserThread::HandleForLoopArguments()'s body:

--- Code: ---...
        if (peek == ParserConsts::comma)
        {
            smallTokenizer.GetToken(); // eat comma
            createNewToken = true;
        }
        else if (peek == ParserConsts::colon
                 || peek == ParserConsts::semicolon
                 || peek.empty())
        {
            createNewToken = true;
            finished = true; // after this point there will be no further declarations
        }
...

--- End code ---
It looks like handling colon is not quite correct. For example:

--- Code: ---for ( SomeNamespace::SomeClass i = 0; ...)

--- End code ---
In this case, it should add a token "i", which the type "SomeNamespace::SomeClass".
The current method is try to construct a small buffer(smallTokenizer), which contains:

--- Code: ---( SomeNamespace::SomeClass i = 0; ...)
--- End code ---
and run some parsing method on it.

My idea could be:
1, Make the buffer "( SomeNamespace::SomeClass i = 0; ...)", and construct a new Parserthread object
2, call DoParse() function recursively on the buffer, which is quite similar with how we parse the class definitions

--- Code: ---class AAA
{
     // body of the class definition, we recursively to call the DoParse() function.
     // So that all tokens are marked as the child token of the Token "AAA".
     // once the "}" is met, the Doparse() will returned to its high level DoParse().
}

--- End code ---
3, if possible, we can let the Token "i" be a child Token of the current Token(ideally the Token "for"), although all the tokens are temporary tokens.

In the main loop of the DoParse(), the "SomeNamespace::SomeClass i = 0;" will be correctly recognized as a Token "i".
This is the way we can handle function parameters, or the catch(xxx) clause, as we have already discussed.

ollydbg:
@Huki, your patches are in trunk now, thanks.

Navigation

[0] Message Index

[*] Previous page

Go to full version