CPSC 421-010 Object-Oriented Programming (OOP) Spring 2023

Project 1: srcFacts

One approach to understanding the source code of a system is to count things, e.g., the number of statements, functions, classes, expressions, LOC (Lines Of Code), etc. The program srcFacts produces a report of these counts.

It is very difficult for a program to directly parse C++ source code, i.e., identify the syntactic parts of the code. So the srcFacts program does not parse the C++ source code. It uses another tool, srcML, to convert the C++ source code into an XML format. The srcFacts program inputs this XML format, parses the XML collecting counts, and produces the report.

The srcFacts program is one large, main() function using almost no design features. It does have high scalability and performance as it is extremely fast and, for example, can produce a report on the entire Linux kernel in under 6 seconds. However, it is not easy in its current form to debug the XML parsing, add additional program element counts, or even understand what is going on. It includes code for parsing all parts of XML, but it would not be easy to adapt the XML parsing code for another purpose, e.g., another report. The only way to reuse this code is by copy/paste reuse. It has no modularity, extensibility, reusability, and specifically no maintainability.

Your task is to take the srcFacts code, improve the overall design, and extract the XML parsing part of the code. When completed, a set of functions in the files xml_parser.hpp and xml_parser.cpp will handle as much XML parsing as possible, while the main program, srcFacts.cpp, generates the report using the XML parser functions for parsing.

The steps (in order) with the associated (git) tag are:

Tag v1a Without changing the design, add the code necessary for the report to include the number of return statements. The heading in the table must be "Returns". Due Jan 24

Tag v1b Move the refillContent() function into the separate refillContent.hpp and refillContent.cpp files. Due Jan 26 27

Tag v1c Apply the specific design changes from the Coding Practices Task List (to appear). As you verify that the code follows the practices given, check them off. Once you have completed all of them, close the issue. Due Jan 29 31 Feb 1

Tag v1d Extract a set of (free) functions to handle the low-level details of the XML parsing. Extract one function at a time, i.e., each commit can only include a single extracted function. These function declarations and definitions belong in the files xml_parser.hpp and xml_parser.cpp, as described above. Due Feb 2 6 9

Tag v1e Add the necessary code to count the number of line comments and the number of literal strings. The headings in the table must be "Line Comments" and "Strings". Due Feb 6 7 10

Your repository for this project is through GitHub Classroom with a link on the Brightspace course page.