Skip to content

A lightweight C++ code analyzer that determines whether a given codebase uses object-oriented programming principles.

Notifications You must be signed in to change notification settings

elunac19/compiler_project

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

compiler_project

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.

Requirements

  • GCC compiler (tested with gcc)
  • Make build system
  • C standard library
  • POSIX-compliant operating system (for directory operations)

Project Structure

.
├── 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

Running Tests

The project includes the following test options:

  1. Comprehensive OOP test suite (provides Accuracy, Precision, Recall stats):
make oop_test
  1. Unit tests:
make unit_test

Building the Project

To build the project, simply run:

make

This will create the following executables in the build directory:

  • unit_test: Unit tests
  • test_runner: Comprehensive test runner

Cleaning Build Files

To remove all compiled binaries:

make clean

Usage

The compiler analyzes C++ source files to determine if they follow object-oriented programming principles. It can be used in two ways:

  1. Direct analysis of a single file:
./build/oop <path_to_cpp_file>
  1. 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

Compiler Grammar

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 → * | & | ε

States

Estado del análisis

About

A lightweight C++ code analyzer that determines whether a given codebase uses object-oriented programming principles.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •