Looking for a few people willing to test!

This is a discussion on Looking for a few people willing to test! within the Projects and Job Recruitment forums, part of the Community Boards category; ok this is a simple c++ syntax highlighting program, i will provide you with the source, the config file. i ...

  1. #1
    Banned
    Join Date
    Jun 2005
    Posts
    594

    Looking for a few people willing to test!

    ok this is a simple c++ syntax highlighting program,
    i will provide you with the source, the config file.

    i need you to find any bugs and comment on suggestions.

    the attached is a zip file containing all you need,
    thanks to everyone in advance.

    this is a sample output

    Code:
    #include <iostream>
    #include <string>
    
    
    using namespace std;
    
    int main()
    {
    	string mysentence = "hello world";
    	cout << mysentence << endl;
    	cout << "welcome to my world" << end;
    	return 0;
    }
    im sure there are some bugs, and plus ive only had
    the oppurtunity of testing it on my style of coding,
    id like you to test it on yours.

    Also the way the config file works, theoritically (i havent tested)
    you could make the output work for html files to.

    Simple take the .txt off the file name and extract, thank you once
    again.
    Attached Files Attached Files

  2. #2
    Banned
    Join Date
    Jun 2005
    Posts
    594
    i noticed one bug, such as when i choose to highlight "string"
    a typically un-highlighted keyword, that it high lights it in
    the #include statment, so i will post an update later.

    also i wanted to go into more detail on how the
    config file works so you can change it to suit you.


    Code:
    char=[ COLOR=Blue]char[/COLOR ]
    (without the spaces of course i did that so you could see)
    that line can be found in the config file
    basically you can look at it as the program search
    for char and replaces it with [ COLOR=Blue]char[ /COLOR]
    so to add on simply add your new word following that
    format. if you would like to use it for html syntax highlighting
    you could do yourword=<font color=#0000ff>yourword</font>
    however it wont preserve your indents, this code is
    mainly used to color code your code for cboard posts.

  3. #3
    Banned
    Join Date
    Jun 2005
    Posts
    594
    good news i worked out one of the bugs, heres what
    the output looks like now with default settings :


    Code:
    #include <iostream>
    #include <string>
    
    
    using namespace std;
    
    int main()
    {
    	//stuff
    	string mysentence = "hello world"; //a string
    	char ch;
    	int eight;
    	cout << mysentence << endl;
    	cout << "welcome to my world" << mysentence << "lalalal" << "uhuuses" << end;
    	return 0;
    }

    and here is the new source
    Attached Files Attached Files
    Last edited by ILoveVectors; 08-12-2005 at 06:13 PM.

  4. #4
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Here's code I tried to highlight:
    Code:
    #pragma once
    
    #include<iostream>
    #include<string>
    
    /* Multi-line comment begins here
       And ends here*/
    
    #ifdef __BORLANDC__
      #error "Borland"
    #else if defined(_MSC_VER)
      #error "Microsoft"
    #endif
    
    using /*midline comment*/namespace std;
    
    int main()
    {
    	string mysentence = "hello bool world";
    	cout << mysentence << endl;
    	cout << "welcome to my world" << end;
    	return 0;
    }
    And here's how it was highlighted:
    Code:
    #pragma once
    
    #include<iostream>
    #include<string>
    
    /* Multi-line comment begins here
       And ends here*/
    
    #ifdef __BORLANDC__
      #error "Borland"
    #else if defined(_MSC_VER)
      #error "Microsoft"
    #endif
    
    using /*midline comment*/namespace std;
    
    int main()
    {
    	string mysentence = "hello bool world";
    	cout << mysentence << endl;
    	cout << "welcome to my world" << end;
    	return 0;
    }
    But here's how it should look:
    Code:
    #pragma once
    
    #include<iostream>
    #include<string>
    
    /* Multi-line comment begins here
       And ends here*/
    
    #ifdef __BORLANDC__
      #error "Borland"
    #else if defined(_MSC_VER)
      #error "Microsoft"
    #endif
    
    using /*midline comment*/namespace std;
    
    int main()
    {
    	string mysentence = "hello bool world";
    	cout << mysentence << endl;
    	cout << "welcome to my world" << end;
    	return 0;
    }
    You've made a good start, but there are a few quirky things and other more obvious things that you need to work out. Fyi, the proper highlighting was done with my codeformatter program (the source is available on my app page if you're at all interested in referencing it).

  5. #5
    Banned
    Join Date
    Jun 2005
    Posts
    594
    the few things that it didnt highlight are because there not in the
    config file you can add them easily.

    as for /* */ comments i havent added support for that,
    so far it just supports // comments

    and i will be doing one more update soon to stop
    the highlighting of words within comments and strings


    your code is pretty cool, and you have a good list of keywords
    that i will add to mine, i just did a quick search and found the
    list that i currently use. one thing cool about my code though
    is because of the config file you have alot of control over
    what you get.

    thank you for testing it out and giving me some comments.
    Last edited by ILoveVectors; 08-12-2005 at 11:29 PM.

  6. #6
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Actually it's not as simple a matter as keywords not being defined. After reviewing a good variety of source from a good variety of sources, you might notice that there are a number of various preprocessor directives that you really can't just define in a config file. It's for that reason that I colorize anything that follows a # until we detect that we should stop.

    Yes, you do have to add support for multi/mid-line comments. There are also several other things you need to take into consideration. For example, you could encounter a // after a /* but before a */, you could encounter a /* after a //, you aren't highlighting characters (e.g., char ch = 'X'), you need to ignore quotes within strings/characters (e.g., char ch = '"'; string str = "\"''\"";), etc.

    It's true that I've hardcoded all of the keywords in my app and I'm sure you noticed how simple it would be to load them from a file since they are all mapped within an independent function anyway, but I left it that way because my intent was simply to highlight all C++ keywords. In any case, I've made the simple modification to my program and now it loads the keywords from a file. It would take little more work to to include the format description, but I'm not going to do that.

    Good luck to you. Keep us updated with your progress.

  7. #7
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Okay, I decided to go ahead and extend the functionality of my app. Look at the included ini file for details. You can define multiple formatting tags for keywords, comments, and strings as well as the type of brackets to use around tags. It's in a pseudo-XML format, but currently it doesn't support values with embedded spaces. It will, however, once I make a few minor modifications to the ini file parser. But, I'll do that later.

  8. #8
    Banned
    Join Date
    Jun 2005
    Posts
    594
    cool looks like i motivated somebody lol,
    anyways i was trying to do mine while
    having the shortest source file as possible.

  9. #9
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    Hehe, yeah, you really did motivate me to implement some great changes. Thanks for that.

    I'd like to see how short you can code yours retaining a minimal amount of code. That'd be interesting.

  10. #10
    Banned
    Join Date
    Jun 2005
    Posts
    594
    new update supports multilined comments, however it still
    highlight words in comments and string, that will be the goal of
    my next update.
    Attached Files Attached Files

  11. #11
    Banned
    Join Date
    Jun 2005
    Posts
    594
    ok major update this time, i still need opinions, and testing,
    there sitll a few thing i have to work out but this good for
    now. also lucky, i was looking and in visual studio, it
    doesnt highlight the word defined so i have choosen
    not to add that word, ive added soem support for words
    with # in front so they dont all have to be in the config
    file. but i choose not to follow the way you suggested,
    i think for the most part it will work out ok.

    as for now the code will nto highlight words inside
    of comments, but it will highlight words within strings.
    Attached Files Attached Files

  12. #12
    Magically delicious LuckY's Avatar
    Join Date
    Oct 2001
    Posts
    856
    I haven't checked out your latest code, but it looks like you're making progress. Good deal.

    Btw, MSVC does in fact highlight "defined" in the context I described earlier, but, either way, you've made your executive decision about how your app should work, so I'm making no attempt to sway you away from it.
    Attached Images Attached Images  

  13. #13
    Banned
    Join Date
    Jun 2005
    Posts
    594
    ah ok i see, i couldnt get it to highlight, i got it now, thanks

  14. #14
    Banned
    Join Date
    Jun 2005
    Posts
    594
    ok another update, it doesnt highlight keywords within
    strings now.


    here the source
    Attached Files Attached Files

  15. #15
    Banned
    Join Date
    Jun 2005
    Posts
    594
    good new i have another update ot accomedate some other
    styles of coding. also i foudn one more bug, where it
    does highligh the same word in the same sentence, my
    next udpate will focus on that till then, here is the next update.

    P.S.
    dont forget to download one of the full release above,
    so you can get the config file, if you havent already done so.
    Attached Files Attached Files

Page 1 of 4 1234 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Katrina Aftermath: Woeful Incompetence (rant).
    By anonytmouse in forum A Brief History of Cprogramming.com
    Replies: 61
    Last Post: 09-05-2005, 08:39 AM
  2. C++ Operator Overloading help
    By Bartosz in forum C++ Programming
    Replies: 2
    Last Post: 08-17-2005, 01:55 PM
  3. February 1, 2019...
    By Cheeze-It in forum A Brief History of Cprogramming.com
    Replies: 98
    Last Post: 08-03-2002, 08:24 AM
  4. Religious Bull****
    By Witch_King in forum A Brief History of Cprogramming.com
    Replies: 119
    Last Post: 10-23-2001, 08:14 AM
  5. IT people - weird genius or simply narrow-minded, antisocial, lazy people
    By Carlos in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 10-11-2001, 06:00 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21