Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => CodeCompletion redesign => Topic started by: Borr on October 22, 2010, 06:33:40 am

Title: wxGetApp not in the list CC
Post by: Borr on October 22, 2010, 06:33:40 am
wxGetApp not in the list CC. Maybe we should try to look at the Eclipse parser algorithm?
Title: Re: wxGetApp not in the list CC
Post by: ollydbg on October 22, 2010, 07:18:31 am
wxGetApp not in the list CC.

confirmed trunk rev 6736.

Just noticed that:

In my D:\code\wxWidgets-2.8.11\include\wx\app.h
The declaration is like:
Code
// this macro can be used multiple times and just allows you to use wxGetApp()
// function
#define DECLARE_APP(appname) extern appname& wxGetApp();

But once the cc's parser meets a extern keyword, it will just skip the later statement.

see the source code: parserthread.cpp line 716
Code
            else if (token == ParserConsts::kw_extern)
            {
                // check for "C", "C++"
                m_Str = m_Tokenizer.GetToken();
                if (m_Str == ParserConsts::kw_C || m_Str == ParserConsts::kw_CPP)
                {
                    m_Tokenizer.GetToken(); // "eat" {
                    DoParse(); // time for recursion ;)
                }
                else
                {
                    // do nothing, just skip keyword "extern", otherwise uncomment:
                    //SkipToOneOfChars(ParserConsts::semicolon); // skip externs
                    m_Tokenizer.UngetToken();
                }
                m_Str.Clear();
            }

So, the solution is:
some times, we will meet many instants of extern forward declaration. shall we add them to the TokensTree??? any good ideas???

Quote
Maybe we should try to look at the Eclipse parser algorithm?
I'm interested in any parsers, but did you give more directions.
I have no idea about Eclipse parser.
Does it a Jave parser? or some one has familiar with it? Does it do a full C++ grammar match? macro expansion?  include expansion?

ollydbg.



Title: Re: wxGetApp not in the list CC
Post by: oBFusCATed on October 22, 2010, 08:57:46 am
... Maybe we should try to look at the Eclipse parser algorithm? ...

Looking at the source code of Eclipse is just a waste of time (I've tried it).
They have buried the useful parts in too many abstractions and patterns, and other "cool" java enterprise s**t.
It is impossible to understand it, unless you're java programmer or you have plenty of time to waste.

Looking at the code of clang will be way more useful :)
Title: Re: wxGetApp not in the list CC
Post by: ollydbg on October 23, 2010, 04:14:12 am
... Maybe we should try to look at the Eclipse parser algorithm? ...

Looking at the source code of Eclipse is just a waste of time (I've tried it).
They have buried the useful parts in too many abstractions and patterns, and other "cool" java enterprise s**t.
It is impossible to understand it, unless you're java programmer or you have plenty of time to waste.

Looking at the code of clang will be way more useful :)

thank you.
I have found that there is a minimal tutorial, see here:
http://amnoid.de/tmp/clangtut/tut.html

this is a step to step tutorial to build a lexer -> preprocesser -> parser. Nice.

But it seems not C++ grammar...
Title: Re: wxGetApp not in the list CC
Post by: ollydbg on October 23, 2010, 05:01:45 am
by the way:
from this wiki:
Clang - Wikipedia, the free encyclopedia (http://en.wikipedia.org/wiki/Clang)

Quote
On June 7, 2010, Apple announced the preview of Xcode 4.0, which includes Clang C++ support as well as direct integration of Clang into the Xcode 4 IDE. This integration provides Xcode with precise code completion, indexing (cross referencing), on the fly detection of errors and warnings, as well as a new Fix It feature, which uses Clang to automatically corrects errors in the code.

On June 10, 2010, Clang/LLVM became an integral part of FreeBSD. While the default compiler being used is still GCC, it's expected that Clang will replace GCC as a default compiler in the future[19].

sounds Clang is powerful !!!
Title: Re: wxGetApp not in the list CC
Post by: Loaden on October 23, 2010, 04:24:07 pm
wxGetApp not in the list CC. Maybe we should try to look at the Eclipse parser algorithm?
You should add this statement.
Code
DECLARE_APP(yourApp)
Works well in here. :lol:
Title: Re: wxGetApp not in the list CC
Post by: jens on October 23, 2010, 06:12:13 pm
Yes it works, but it should not be needed, if IMPLEMENT_APP is used, because it implicitely calls DECLARE_APP, but it might be to deep in macro-replacement.
Using DECLARE_APP multiple times should be okay, but it's not intuitive to do it this way.
Title: Re: wxGetApp not in the list CC
Post by: Borr on November 10, 2010, 02:25:13 pm
СС with Qt Creator powerful too