Thread: question about parser??

  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    15

    question about parser??

    Hi,

    I am still new to C++ and have a quick question:

    what exactly is a parser??

    Thanks for any explanations.

  2. #2
    Registered User
    Join Date
    Mar 2002
    Posts
    1,595
    To parse something means to break it into smaller pieces. For example, say you have the string:

    Hello world!

    You can parse this string into two substrings based on the space between the two words. You can parse it into 4 three letter strings if you want. You can parse it into 12 individual charactters if you prefer. You can parse it into three strings using the character '0' as a delimiter. You can parse it into 4 strings using the character 'l' as a delimiter. etc. etc. etc.

    As another example you can parse an int like: 321
    into three individual ints using a sequence of % and / in combination.

    int num = 321;
    int parsed[3];
    parsed[2] = num % 10;
    num /= 10;
    parsed[1] = num % 10;
    num /= 10;
    parsed[0] = num;

    for(int i = 0; i < 3; ++i)
    cout << num << endl;

    You have to decide how you want to break down (parse) whatever it is you want to parse. A parser is a routine that does the parsing.
    Last edited by elad; 07-30-2003 at 09:28 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Alice....
    By Lurker in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 06-20-2005, 02:51 PM
  2. Debugging question
    By o_0 in forum C Programming
    Replies: 9
    Last Post: 10-10-2004, 05:51 PM
  3. Question about pointers #2
    By maxhavoc in forum C++ Programming
    Replies: 28
    Last Post: 06-21-2004, 12:52 PM
  4. Question...
    By TechWins in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  5. Question, question!
    By oskilian in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 12-24-2001, 01:47 AM