A lightweight C++ code analyzer that determines whether a given codebase uses object-oriented programming principles.
The compiler is based on a custom grammar designed for LALR(1) parsing, enabling efficient and unambiguous syntax analysis.
- GCC compiler (tested with gcc)
- Make build system
- C standard library
- POSIX-compliant operating system (for directory operations)
.
├── build/ # Compiled binaries
├── libs/ # Third-party libraries
├── compiler.c # Main compiler implementation
├── compiler.h # Header file
├── test_runner.c # Test runner implementation
└── Makefile # Build configuration
The project includes the following test options:
- Comprehensive OOP test suite (provides Accuracy, Precision, Recall stats):
make oop_test- Unit tests:
make unit_testTo build the project, simply run:
makeThis will create the following executables in the build directory:
unit_test: Unit teststest_runner: Comprehensive test runner
To remove all compiled binaries:
make cleanThe compiler analyzes C++ source files to determine if they follow object-oriented programming principles. It can be used in two ways:
- Direct analysis of a single file:
./build/oop <path_to_cpp_file>- Batch analysis of multiple files:
./build/test_runner <valid_oop_dir> <invalid_oop_dir>The test runner will provide detailed statistics about the analysis, including:
- Accuracy
- Precision
- Recall
- Valid/Invalid file detection rates
A → C
C → B C | ε
B → D | E F
F → ( G ) { } | ;
D → class id J { } ;
J → : K | ε
K → K , L | L
L → M id | id
M → public | private | protected
G → N | ε
N → N , E | E
E → O P id
O → int | char | long | float | double | string | void | id
P → * | & | ε
