regex_token_iterator

  1. Prompt the user to input a ".cpp" file.
  2. Use the regex_token_iterator which you learned in fig23_05.cpp to extract all keywords, idenfifiers, and functions in a C++ source program.
    1. C++ has a list of keywords.
    2. Functions has a pair of parenthesis "()".
    3. Identifiers are composed by alphanumeric characters and underscores, but the first character cannot be a digit.
  3. Count the occurrence of each identifier.
  4. If your code relies on external files to recognize C++ keywords, please name it as "c++_keyword.txt" and submit it together with your .cpp file.

Given a source code as follows:

#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main()
{
    int number;
    cin >> number;
    if (number > 10)
        cout << number << endl;
    return 0;
}

the output may look like:

Please input the filename of a C++ program (.cpp) -- a.cpp

if     1   cin      2   main() 1
int    2   cout     2
return 1   endl     2
using  3   include  1
           iostream 1
           number   3
           std      3