How would you write a parser to count the number of functions or methods defined in a given C/C++ source file?