regex_token_iterator
- Prompt the user to input a ".cpp" file.
- Use the regex_token_iterator which you learned in
fig23_05.cpp
to extract all keywords, idenfifiers, and functions in a C++ source
program.
- C++ has a list of keywords.
- Functions has a pair of parenthesis "()".
- Identifiers are composed by alphanumeric characters and
underscores, but the first character cannot be a digit.
- Count the occurrence of each identifier.
- 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