Author Topic: code completion plugin parser test project with cmd  (Read 9227 times)

Offline visualfc

  • Single posting newcomer
  • *
  • Posts: 9
    • http://code.google.com/p/visualfc
code completion plugin parser test project with cmd
« on: December 03, 2009, 01:45:23 pm »
Helo, I make cctest , a eary test CodeBlocks codecompletion function to parser cpp file program.
The cctest modify CodeCompletion Token and ParserThread lib, only use STL, a std::string and std::wstring (#define CC_UNICODE) , I'm test by WX and QT. cctest project is make by CodeBlocks, build and run on WindowXP and Ubuntu 64bit.

new download source cctest_v3.zip

cctest run on WindowXP 32bit
Code
Hello world! C++ Parser Programing!
-> cmd: (load,files,clear)  (list,tree,show,dump) (log,logoff) (help,exit) log=off
        load  filename               load c++ file path
        files                        show load files
        clear                        clear all files
        list                         show token by list
        tree                         show token by tree
        show  n                      show signal file token  by tree
        dump                         dump token tree
        log  filename                setup log filepath
        logoff                       setup log = std::cout
        help                         show this help
        exit                         exit application
-> log d:\log.txt
log=d:\log.txt
-> load d:\project\cctest\main.cpp
load file ok! d:\project\cctest\main.cpp
-> tree
+class FileLoader {...} [24,0]
|       data()  [28,28]
|       length()        [32,32]
|       fileName()      [36,36]
|       FileLoader::FileLoader(const char* fileName)    [40,40]
|       isLoad()        [45,45]
|       load()  [50,50]
|       char * FileLoader::name [61,0]
|       char * FileLoader::buf  [62,0]
|       int FileLoader::buf_size        [63,0]
+class ParserClient {...}       [66,0]
|       ParserClient::ParserClient()    [70,70]
|       ParserClient::~ParserClient()   [74,74]
|       parser(const char * fileName)   [78,78]
|       clear() [100,100]
|       GetFullFileName(const cc_string & Filename,const cc_string& filename,bool isGlobal)     [106,106]
|       OnParseFile(const cc_string & filename, int flag)       [110,110]
|       printToken(std::ostream & f, Token* tk, const string & head)    [114,114]
|       printTokenTree(std::ostream & f, Token* tk, const string & head)        [127,127]
|       printList(std::ostream & f)     [138,138]
|       printTree(std::ostream & f)     [148,148]
|       printFiles(std::ostream & f)    [161,161]
|       printFileToken(std::ostream & f, int n) [168,168]
|       TokensTree * ParserClient::tree [184,0]
|       vector ParserClient::files      [185,0]
showHelp(std::string & logname) [189,189]
main()  [206,206]
-> dump
- "" (0)
      +- "FileLoader" (1)
      +- "GetFullFileName" (14)
      +- "OnParseFile" (15)
      +- "ParserClient" (10)
      +- "buf_size" (9)
      +- "clear" (13)
      +- "data" (2)
      +- "file" (26)
      |           +- "Name" (4)
      |           \- "s" (27)
      +- "isLoad" (5)
      +- "l" (6)
      |       +- "ength" (3)
      |       \- "oad" (7)
      +- "main" (29)
      +- "name" (8)
      +- "p" (16)
      |        +- "arser" (12)
      |        \- "rint" (18)
      |                    +- "File" (23)
      |                    |           +- "Token" (24)
      |                    |           \- "s" (22)
      |                    +- "List" (19)
      |                    \- "T" (20)
      |                             +- "okenTree" (17)
      |                             \- "ree" (21)
      +- "showHelp" (28)
      +- "tree" (25)
      \- "~ParserClient" (11)
->exit


cctest run on Ubuntu9.10 64-bit cclog file text
Code
log time: Mon Dec  7 14:58:25 2009


command:load
load file:/home/win32/share/cctest/main.cpp

command:files
0. /home/win32/share/cctest/main.cpp

command:show
show file:/home/win32/share/cctest/main.cpp
+class FileLoader {...} [24,0]
| data() [27,27]
| length() [31,31]
| fileName() [35,35]
| FileLoader::FileLoader(const char* fileName) [40,40]
| isLoad() [44,44]
| load() [49,49]
| char * FileLoader::name [61,0]
| char * FileLoader::buf [62,0]
| int FileLoader::buf_size [63,0]
+class ParserClient {...} [66,0]
| ParserClient::ParserClient() [69,69]
| ParserClient::~ParserClient() [73,73]
| parser(const char * fileName) [77,77]
| clear() [99,99]
| GetFullFileName(const cc_string & Filename,const cc_string& filename,bool isGlobal) [105,105]
| OnParseFile(const cc_string & filename, int flag) [109,109]
| printToken(std::ostream & f, Token* tk, const string & head) [113,113]
| printTokenTree(std::ostream & f, Token* tk, const string & head) [126,126]
| printList(std::ostream & f) [137,137]
| printTree(std::ostream & f) [148,148]
| printFiles(std::ostream & f) [161,161]
| printFileToken(std::ostream & f, int n) [168,168]
| TokensTree * ParserClient::tree [185,0]
| vector ParserClient::files [186,0]
showHelp(std::string & logname) [189,189]
main() [206,206]

command:tree
+class FileLoader {...} [24,0]
| data() [27,27]
| length() [31,31]
| fileName() [35,35]
| FileLoader::FileLoader(const char* fileName) [40,40]
| isLoad() [44,44]
| load() [49,49]
| char * FileLoader::name [61,0]
| char * FileLoader::buf [62,0]
| int FileLoader::buf_size [63,0]
+class ParserClient {...} [66,0]
| ParserClient::ParserClient() [69,69]
| ParserClient::~ParserClient() [73,73]
| parser(const char * fileName) [77,77]
| clear() [99,99]
| GetFullFileName(const cc_string & Filename,const cc_string& filename,bool isGlobal) [105,105]
| OnParseFile(const cc_string & filename, int flag) [109,109]
| printToken(std::ostream & f, Token* tk, const string & head) [113,113]
| printTokenTree(std::ostream & f, Token* tk, const string & head) [126,126]
| printList(std::ostream & f) [137,137]
| printTree(std::ostream & f) [148,148]
| printFiles(std::ostream & f) [161,161]
| printFileToken(std::ostream & f, int n) [168,168]
| TokensTree * ParserClient::tree [185,0]
| vector ParserClient::files [186,0]
showHelp(std::string & logname) [189,189]
main() [206,206]

command:list
class          class FileLoader {...} [24,0]
function       char * FileLoader::data() [27,27]
function       unsigned int FileLoader::length() [31,31]
function       char * FileLoader::fileName() [35,35]
constructor    FileLoader::FileLoader(const char* fileName) [40,40]
function       bool FileLoader::isLoad() [44,44]
function       void FileLoader::load() [49,49]
variable       char * FileLoader::name [61,0]
variable       char * FileLoader::buf [62,0]
variable       int FileLoader::buf_size [63,0]
class          class ParserClient {...} [66,0]
constructor    ParserClient::ParserClient() [69,69]
destructor     ParserClient::~ParserClient() [73,73]
function       bool ParserClient::parser(const char * fileName) [77,77]
function       void ParserClient::clear() [99,99]
function       cc_string ParserClient::GetFullFileName(const cc_string & Filename,const cc_string& filename,bool isGlobal) [105,105]
function       void ParserClient::OnParseFile(const cc_string & filename, int flag) [109,109]
function       void ParserClient::printToken(std::ostream & f, Token* tk, const string & head) [113,113]
function       void ParserClient::printTokenTree(std::ostream & f, Token* tk, const string & head) [126,126]
function       void ParserClient::printList(std::ostream & f) [137,137]
function       void ParserClient::printTree(std::ostream & f) [148,148]
function       void ParserClient::printFiles(std::ostream & f) [161,161]
function       void ParserClient::printFileToken(std::ostream & f, int n) [168,168]
variable       TokensTree * ParserClient::tree [185,0]
variable       vector ParserClient::files [186,0]
function       void showHelp(std::string & logname) [189,189]
function       int main() [206,206]

command:dump
- "" (0)
      +- "FileLoader" (1)
      +- "GetFullFileName" (14)
      +- "OnParseFile" (15)
      +- "ParserClient" (10)
      +- "buf_size" (9)
      +- "clear" (13)
      +- "data" (2)
      +- "file" (26)
      |           +- "Name" (4)
      |           \- "s" (27)
      +- "isLoad" (5)
      +- "l" (6)
      |       +- "ength" (3)
      |       \- "oad" (7)
      +- "main" (29)
      +- "name" (8)
      +- "p" (16)
      |        +- "arser" (12)
      |        \- "rint" (18)
      |                    +- "File" (23)
      |                    |           +- "Token" (24)
      |                    |           \- "s" (22)
      |                    +- "List" (19)
      |                    \- "T" (20)
      |                             +- "okenTree" (17)
      |                             \- "ree" (21)
      +- "showHelp" (28)
      +- "tree" (25)
      \- "~ParserClient" (11)

command:clear
clear all files

command:help

command:exit

[attachment deleted by admin]
« Last Edit: December 07, 2009, 08:06:52 am by visualfc »

Offline blueshake

  • Regular
  • ***
  • Posts: 459
Re: a cc parser test project with cmd
« Reply #1 on: December 03, 2009, 02:06:19 pm »
Note:


VisualFC had separated the parser from the codecompletion.and he made some change.
1.he changed the wxSting to string,so the parser use purely stl lib now.

2. you can  switch between  wstring and string by define CC_UNICODE under wx or QT project.

3.in this cmd-project ,only string is supported.

4.you can use cb to build this project.After built and run,the program will ask you to input the file which you want to parse.and then you can use command "tree" to see the output.

welcome to test and thanks visualfc
« Last Edit: December 05, 2009, 01:31:43 pm by blueshake »
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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: code completion plugin parser test project with cmd
« Reply #2 on: December 03, 2009, 05:05:26 pm »
Great, if this thing works (can't test it at the moment), we are one step closer to automated testing of the codecompletion code :)

Keep going:)
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: code completion plugin parser test project with cmd
« Reply #3 on: December 05, 2009, 07:04:49 am »
I just tested this program. It works OK!

The only drawback is that Console window has limited width, so, there are some sentences wrapping in the output. :(

Edit:

How about using the Rickg22's Token Trie output function. see rickg22's SearchTree development
« Last Edit: December 05, 2009, 07:07:35 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: 459
Re: code completion plugin parser test project with cmd
« Reply #4 on: December 05, 2009, 11:36:45 am »
I just tested this program. It works OK!

The only drawback is that Console window has limited width, so, there are some sentences wrapping in the output. :(

Edit:

How about using the Rickg22's Token Trie output function. see rickg22's SearchTree development


I have suggest visualfc to output the result to file.but he is busy with his qt plugin.so ...
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: 459
Re: code completion plugin parser test project with cmd
« Reply #5 on: December 05, 2009, 12:02:48 pm »
I update visualfc's project.


I just add the command "show".

with this command, you can show the tokens in the file you assign, not all the files' tokens.


steps:
1.show
2.input the file number according to the file list tips.


welcome to test it.

[attachment deleted by admin]
« Last Edit: December 05, 2009, 12:05:25 pm by blueshake »
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 visualfc

  • Single posting newcomer
  • *
  • Posts: 9
    • http://code.google.com/p/visualfc
Re: code completion plugin parser test project with cmd
« Reply #6 on: December 07, 2009, 07:47:41 am »
I make new download source cctest_v3.zip

change log:

1. load
  load filename
2. dump
   searchtree dump
3. log
   output log filename
4. show
   show one file token
Code
Hello world! C++ Parser Programing!
-> cmd: (load,files,clear)  (list,tree,show,dump) (log,logoff) (help,exit) log=off
        load  filename               load c++ file path
        files                        show load files
        clear                        clear all files
        list                         show token by list
        tree                         show token by tree
        show  n                      show signal file token  by tree
        dump                         dump token tree
        log  filename                setup log filepath
        logoff                       setup log = std::cout
        help                         show this help
        exit                         exit application
-> log d:\log.txt
log=d:\log.txt
-> load d:\project\cctest\main.cpp
load file ok! d:\project\cctest\main.cpp
-> tree
+class FileLoader {...} [24,0]
|       data()  [28,28]
|       length()        [32,32]
|       fileName()      [36,36]
|       FileLoader::FileLoader(const char* fileName)    [40,40]
|       isLoad()        [45,45]
|       load()  [50,50]
|       char * FileLoader::name [61,0]
|       char * FileLoader::buf  [62,0]
|       int FileLoader::buf_size        [63,0]
+class ParserClient {...}       [66,0]
|       ParserClient::ParserClient()    [70,70]
|       ParserClient::~ParserClient()   [74,74]
|       parser(const char * fileName)   [78,78]
|       clear() [100,100]
|       GetFullFileName(const cc_string & Filename,const cc_string& filename,bool isGlobal)     [106,106]
|       OnParseFile(const cc_string & filename, int flag)       [110,110]
|       printToken(std::ostream & f, Token* tk, const string & head)    [114,114]
|       printTokenTree(std::ostream & f, Token* tk, const string & head)        [127,127]
|       printList(std::ostream & f)     [138,138]
|       printTree(std::ostream & f)     [148,148]
|       printFiles(std::ostream & f)    [161,161]
|       printFileToken(std::ostream & f, int n) [168,168]
|       TokensTree * ParserClient::tree [184,0]
|       vector ParserClient::files      [185,0]
showHelp(std::string & logname) [189,189]
main()  [206,206]
-> dump
- "" (0)
      +- "FileLoader" (1)
      +- "GetFullFileName" (14)
      +- "OnParseFile" (15)
      +- "ParserClient" (10)
      +- "buf_size" (9)
      +- "clear" (13)
      +- "data" (2)
      +- "file" (26)
      |           +- "Name" (4)
      |           \- "s" (27)
      +- "isLoad" (5)
      +- "l" (6)
      |       +- "ength" (3)
      |       \- "oad" (7)
      +- "main" (29)
      +- "name" (8)
      +- "p" (16)
      |        +- "arser" (12)
      |        \- "rint" (18)
      |                    +- "File" (23)
      |                    |           +- "Token" (24)
      |                    |           \- "s" (22)
      |                    +- "List" (19)
      |                    \- "T" (20)
      |                             +- "okenTree" (17)
      |                             \- "ree" (21)
      +- "showHelp" (28)
      +- "tree" (25)
      \- "~ParserClient" (11)
->exit
« Last Edit: December 07, 2009, 08:02:44 am by visualfc »

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: code completion plugin parser test project with cmd
« Reply #7 on: December 07, 2009, 02:33:14 pm »
Great!
I have one question:

Is it possible to integrate with the current C::B's code? It seems you have some dummy class in cchelper.h, such as:

Code
class wxFile
{
public:
    wxFile(const cc_string & fileName) : m_file(fileName)
    {
    }
    size_t length()
    {
        return 0;
    }

    cc_string m_file;
};

@morten: What about your idea? thanks.
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 visualfc

  • Single posting newcomer
  • *
  • Posts: 9
    • http://code.google.com/p/visualfc
Re: code completion plugin parser test project with cmd
« Reply #8 on: December 07, 2009, 03:11:26 pm »
Quote
Is it possible to integrate with the current C::B's code? It seems you have some dummy class in cchelper.h, such as:

Code:

class wxFile
{
public:
    wxFile(const cc_string & fileName) : m_file(fileName)
    {
    }
    size_t length()
    {
        return 0;
    }

    cc_string m_file;
};


@morten: What about your idea?

I have step by step make the cc port, First compatible then transplantation, In order to avoid problems.
A cctest currentlyis only cc function test. and change the wx to stl.
« Last Edit: December 07, 2009, 03:18:03 pm by visualfc »