Question: Parsing C Programs Create a perl script called cparse.pl that counts tokens in a C program. The name of the program (file) shall be specified
Parsing C Programs Create a perl script called cparse.pl that counts tokens in a C program. The name of the program (file) shall be specified via the command line. Thus, the program should be invoked from the command line via:
perl cparse.pl mainProg.c
For each line of the C program cparse.pl should output: 1. The number of words (variable and reserved) on the line. 2. The number of numeric literals without decimal points on the line. 3. The number of numeric literals with decimal points on the line. 4. The number of braces, brackets and parentheses on the line. Finally, the script should output the total number of each of the four classes, above, that were in the entire program.
Here is what the end of output might look like: Words: 8 Ints: 1 Floats: 2 Braces: 4 Words: 3 Ints: 0 Floats: 0 Braces: 2 ================================================ TOTALS: Words: 435 Ints: 23 Floats: 8 Braces: 64
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
