News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

vector<int> is OK, but string or wstring no-work.

Started by Loaden, January 06, 2010, 05:39:50 AM

Previous topic - Next topic

MortenMacFly

Quote from: ollydbg on January 17, 2010, 02:36:07 PM
Great! Why the "!" is missing........It seems we haven't change this function.
My fault. I was removing the artifacts from the past where there used to be a parser per project. So I changed all references to "per project parser" to the global none and obviously missed the !" there. Sorry. Will fix asap...
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

Loaden

Quote from: blueshake on January 17, 2010, 02:14:25 PM
Quote from: Loaden on January 17, 2010, 12:53:04 PM
#include <iostream>
#include <map>
#include <string>

int main()
{
   typedef std::map<int, std::string> TestMap;
   TestMap testMap;
//    testMap. // not work!

   std::map<int, std::string> m;
   m.insert(1, "Hello World!"); // work fine.
   return 0;
}


@Loaden
you can not typedef something in the function body.The reason is not clear for me,maybe ollydbg or morten can release some answers. :D
#include <iostream>
#include <map>
#include <string>

typedef std::map<int, std::string> TestMap;

class A
{
public:
    void Test()
    {
        TestMap2 t2;
        t2.in // works here too.
    }
   
private:
    typedef std::map<int, std::string> TestMap2;
}

int main()
{
    TestMap testMap;
    testMap.i // ok, work now.
    return 0;
}



[attachment deleted by admin]

Loaden

New bug:
#include <iostream>

int main()
{
   // std::cou // not work!
   std::endl // work here.
   return 0;
}


[attachment deleted by admin]

Loaden

There's a small problem.


[attachment deleted by admin]

MortenMacFly

Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

blueshake

Quote#include <iostream>

int main()
{
    // std::cou // not work!
    std::endl // work here.
    return 0;
}


where is the definition of std::cout???
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?

MortenMacFly

Quote from: blueshake on January 18, 2010, 03:06:52 AM
where is the definition of std::cout???
Directly in iostream:
  extern istream cin; ///< Linked to standard input
  extern ostream cout; ///< Linked to standard output
  extern ostream cerr; ///< Linked to standard error (unbuffered)
  extern ostream clog; ///< Linked to standard error (buffered)

And yes: It's "gone". ?!
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

ollydbg

#97
In my opinion: In the parserThread DoParse function, when it meet the "extern" keyword, the parser just skip to the the ";".
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.

blueshake

Quote from: ollydbg on January 18, 2010, 06:55:36 AM
In my opinion: In the parserThread DoParse function, when it meet the "extern" keyword, the parser just skip to the the ";".

right.that is why I ask where is the real definition.if it is just so,we need to  do some handle about extern.
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?

MortenMacFly

Quote from: ollydbg on January 18, 2010, 06:55:36 AM
In my opinion: In the parserThread DoParse function, when it meet the "extern" keyword, the parser just skip to the the ";".
No, the code is question is as follows:

        else if (token==ParserConsts::kw_extern)
        {
            // check for "C"
            m_Str = m_Tokenizer.GetToken();
            if (m_Str==ParserConsts::kw_C)
            {
                m_Tokenizer.GetToken(); // "eat" {
                DoParse(); // time for recursion ;)
            }
            else
            {
                // do nothing, just skip keyword "extern", otherwise uncomment:
                //SkipToOneOfChars(ParserConsts::semicolon); // skip externs
            }
            m_Str.Clear();
        }

As you see: Really only "extern" is skipped, the rest is parsed as usual.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

blueshake

#100
           m_Str = m_Tokenizer.GetToken();
           if (m_Str==ParserConsts::kw_C)
           {
               m_Tokenizer.GetToken(); // "eat" {
               DoParse(); // time for recursion ;)
           }
           else
           {
               // do nothing, just skip keyword "extern", otherwise uncomment:
               //SkipToOneOfChars(ParserConsts::semicolon); // skip externs
           }
           m_Str.Clear();


it seems I get the reason.

e.g. extern int aa;

when we do this.
m_Str = m_Tokenizer.GetToken();

now the m_Str is int.


but here we clear the m_Str again.
m_Str.Clear();

so the m_Str is empty.I think this is why the cout can not be parsed correctly.

solution :

comment this statement may work.

//m_Str.Clear();
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?

blueshake

Quote from: Loaden on January 17, 2010, 04:32:08 PM
New bug:
#include <iostream>

int main()
{
   // std::cou // not work!
   std::endl // work here.
   return 0;
}



patch for it.

Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 6089)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -524,7 +524,7 @@
         else if (token==ParserConsts::kw_extern)
         {
             // check for "C"
-            m_Str = m_Tokenizer.GetToken();
+            m_Str = m_Tokenizer.PeekToken();
             if (m_Str==ParserConsts::kw_C)
             {
                 m_Tokenizer.GetToken(); // "eat" {


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?

MortenMacFly

#102
Quote from: blueshake on January 18, 2010, 09:00:15 AM
patch for it.
Index: src/plugins/codecompletion/parser/parserthread.cpp
            // check for "C"
-            m_Str = m_Tokenizer.GetToken();
+            m_Str = m_Tokenizer.PeekToken();
            if (m_Str==ParserConsts::kw_C)
            {
                m_Tokenizer.GetToken(); // "eat" {

Be careful: In that case not the "{" is "eaten" in the case of extern C {...} statements, but the "C". So your patch will work for the extern cout thing, but will break extern C {...}.
This maybe corrected by issuing "m_Tokenizer.GetToken();" twice in the if clause, the fiorst time for "C", the second time for the "{".
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: [url="https://www.codeblocks.org/docs/main_codeblocks_en.html"]https://www.codeblocks.org/docs/main_codeblocks_en.html[/url]
C::B FAQ: [url="https://wiki.codeblocks.org/index.php?title=FAQ"]https://wiki.codeblocks.org/index.php?title=FAQ[/url]

blueshake

hi,morten:
what about this way.
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 6089)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -534,6 +534,7 @@
             {
                 // do nothing, just skip keyword "extern", otherwise uncomment:
                 //SkipToOneOfChars(ParserConsts::semicolon); // skip externs
+                m_Tokenizer.UngetToken();
             }
             m_Str.Clear();
         }
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?

Loaden

Quote from: blueshake on January 18, 2010, 09:09:13 AM
hi,morten:
what about this way.
Index: src/plugins/codecompletion/parser/parserthread.cpp
===================================================================
--- src/plugins/codecompletion/parser/parserthread.cpp (revision 6089)
+++ src/plugins/codecompletion/parser/parserthread.cpp (working copy)
@@ -534,6 +534,7 @@
             {
                 // do nothing, just skip keyword "extern", otherwise uncomment:
                 //SkipToOneOfChars(ParserConsts::semicolon); // skip externs
+                m_Tokenizer.UngetToken();
             }
             m_Str.Clear();
         }

Work now! :P