News:

When registered with our forums, feel free to send a "here I am" post here to differ human beings from SPAM bots.

Main Menu

Patch for handle preprocessor - V2 - beta 3

Started by Loaden, April 17, 2010, 07:42:26 PM

Previous topic - Next topic

daniloz

@ollydbg
Quote from: ollydbg on April 23, 2010, 04:01:13 PM
Note: the comment:
/ /NOTE: it actually forces reparsing of workspace

Ok, it seems this is part of some testing or debug or ... ????

Quote from: ollydbg on April 23, 2010, 04:01:13 PM
I'm grad you have interests to debug and test CC. I would like to do my best to help  :D

My pleasure! Actually, I use C::B for almost an year now and I'm very happy with it, so any help I can bring to you guys is a pleasure for me. By the way, I'm glad you see my questions and "features requests" as a help. I wish I could do more and really get into the code, but right now I really don't have time for that... maybe in the future... :-)

Loaden

#16
Version 2 Change Log:
1. Move condition preprocessor handle from ParserThread to Tokenizer class
2. Support parse like this demo:
#define AAA

void test(int testInt1 // some comment
#ifdef AAA // test
, int testInt2)
#else
)
#endif
{
   tes|
};

3. Rewrote SkipXXX functions.
4. Make argument support default value, like (int i, bool b = true)
5. Fixed some bugs.

ollydbg

Quote from: Loaden on April 30, 2010, 04:43:34 PM
Version 2 Change Log:
1. Move condition preprocessor handle from ParserThread to Tokenizer class
2. Support parse like this demo:
#define AAA

void test(int testInt1 // some comment
#ifdef AAA // test
, int testInt2)
#else
)
#endif
{
   tes|
};

3. Rewrote SkipXXX functions.
4. Make argument support default value, like (int i, bool b = true)
5. Fixed some bugs.

Nice! You patch is far more better than my original patch of "conditional preprocessor handling" in the Parsertest project ( I original posted in ParserTester for codecompletion plugin)

@morten,
As I have explained in this post: Re: Rewrote the DoParse function.
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.

Loaden

#18
V2 - Beta 2 Change Log:
1. Fixed some bugs.
2. Add #undef handle
3. Refactoring Expression

NOTE: If need skip default value, just replace GetArgument with this.
wxString Tokenizer::GetArgument()
{
    wxString arg;
    int nestLevel = 0;
    bool skipEqual = false;
    while (NotEOF())
    {
        while (SkipComment())
            ;

        wxChar ch = CurrentChar();
        if (ch == _T('('))
        {
            ++nestLevel;
            arg.Trim(true);
        }
        else if (ch == _T(')'))
        {
            skipEqual = false;
            --nestLevel;
            arg.Trim(true);
        }

        unsigned int index = m_TokenIndex;
        while (ch == _T('#'))
        {
            if (!HandleConditionPreprocessor())
                break;
            ch = CurrentChar();
        }

        if (ch == _T(','))
        {
            skipEqual = false;
            arg.Trim(true);
            arg.Append(_T(", "));
        }
        else if (ch == _T('='))
            skipEqual = true;
        else if (!skipEqual && ((ch > _T(' ')) || (ch == _T(' ') && arg.Last() != _T(' '))))
            arg.Append(ch);

        if (index == m_TokenIndex)
            MoveToNextChar();

        if (nestLevel == 0)
            break;
    }

    return arg;
}

Loaden

V2 - Beta 3 Change Log:
1. Replace from 'GetArgument' to 'ReadBlock'.
2. Fix bugs.

Loaden

Quote from: Loaden on May 01, 2010, 07:54:04 PM
V2 - Beta 3 Change Log:
1. Replace from 'GetArgument' to 'ReadBlock'.
2. Fix bugs.
I test "V2 - Beta 3" on ArchLinux,  and seems works well. :D