C Code Comprehension is a software tool developed to help beginners understand and analyze C source code. It provides static and dynamic analysis of C programs through lexical tokenization, line-by-line interpretation, and intermediate value tracing of variables.
- Preprocesses source code by removing comments and blank lines.
- Performs tokenization into:
- Identifiers
- Keywords
- Operators
- Literals
- Comments
- Interprets tokens line by line using a map-based data structure.
- Detects common syntax errors:
- Missing semicolons
- Incorrect
&usage inscanf
- Executes C source code line by line in a controlled environment.
- Tracks and displays intermediate variable values throughout execution.
- Determines the path taken by conditional statements (
if/else).
- Developed in C++ using file handling, string processing, and external compilation.
- Implements a tokenization engine using character classification and string pattern matching.
- Dynamic execution is performed via:
- Writing each line of the original source into a separate
testCode.c - Compiling and executing this test file
- Capturing outputs to a result file
- Writing each line of the original source into a separate
Input C Code → Preprocessing → Tokenization → Interpretation → Error Detection
Input C Code → Write Line to testCode.c → Compile & Execute → Output Variable Values
Given a simple C program with variable assignments and conditionals, 3C will:
- Display a structured breakdown of tokens
- Highlight errors like missing semicolons
- Trace the evolution of each variable through dynamic execution
Clone the project
git clone https://github.com/samdani91/SPL-1Dynamic Analysis
cd Dynamic AnalysisRun
g++ dynamicAnalysis.cppStatic Analysis
g++ main.cpp tokenHelp.cpp tokenization.cpp interpretFunc.cpp -o testrun
Run
./testrun- Deep dive into C++ file handling and project structuring
- Managing line-by-line execution of code within another program
- Designing a token interpreter from scratch
- Support for:
- Nested loops
- Multiple functions
- Complex expressions
- More comprehensive error detection
- GUI-based interface for better usability
A. M Samdani Mozumder
BSSE Roll No.: 1412
Session: 2021–2022
Institute of Information Technology, University of Dhaka