Project 1: srcFacts Posted: January 30, 2020

Special Note: You are required to fill out the Checklist issue in your repository as part of Project 1.

One approach to understanding the source code of a system is to know the count of things, including counts of statements, functions, classes, expressions, LOC (Lines Of Code), etc. The program srcFacts does that for you in the form of a report.

Directly parsing C++ source code is very challenging, so the srcFacts code does not directly parse the source code. It uses another tool, srcML, to convert the C++ source code into an XML format. The srcFacts program inputs this XML format. As srcFacts parses the XML, it collects data and produces a report.

The srcFacts program has high scalability and performance as it is quite fast and, for example, can produce a report on the entire Linux kernel in under 20 seconds. However, it is in one large, main program with almost no design. In the current form, it isn’t easy to debug the XML parsing, add additional counts, or even understand what is going on. It includes the code for parsing all parts of XML, but it would be difficult to adapt the XML parsing code for another purpose, e.g., another report. The only way to resuse this code is by copy/paste reuse. It has no modularity, extensibility, or reusability, and specifically no maintainability.

Your task is to take the 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 handle as much of the XML parsing as it can, 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” Move the refillBuffer() function into a separate refillBuffer.hpp and refillBuffer.cpp files. Due Feb 6

Tag “v1b” Without changing the design, add the code necessary for the report to include the number of return statements and the number of literal strings. Due Feb 6

Tag “v1c” Extract a set of (free) functions to handle the low-level details of the XML parsing. Each commit can only include a single extracted function (i.e., extract one at a time). Due Feb 18

Tag “v1d” Add the necessary code to count the number of block comments. Due Feb 18

Your repository for this project is through GitHub Classroom. A link to create the repository is available on the Brightspace course page. Make sure to login to the GitHub account that you are going to use before you click the link.