Skip to content

FlyingBanana06/Compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

17 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ฆ Code Runner for C / C++ / Python

A lightweight command-line tool that compiles and runs single-source files in C, C++, or Python. Designed for quick testing and simple workflows, this utility validates input, handles compilation, and executes code with user-friendly prompts and error messages.


๐Ÿ“ Project Structure

.
โ”œโ”€โ”€ bin/           # Final compiled executable goes here (e.g., compiler)
โ”œโ”€โ”€ input/         # Input source files (.c, .cpp, .py)
โ”œโ”€โ”€ output/        # Output directory for compiled executables
โ”œโ”€โ”€ src/
โ”‚   โ”œโ”€โ”€ main.cpp         # Main logic and user interaction
โ”‚   โ”œโ”€โ”€ header.hpp       # Function declarations and macros
โ”‚   โ””โ”€โ”€ header.cpp       # Implementation for file checks and validation
โ””โ”€โ”€ README.md      # Project documentation (youโ€™re reading it!)

๐Ÿ› ๏ธ How to Build

To compile the runner, use the following command:

g++ src/main.cpp src/header.cpp -std=c++17 -o bin/compiler

โœ… Make sure all the bin/, input/ and output/ directories exists before running the command. If it doesnโ€™t, create it with:

mkdir bin input output

Once compiled and folders are ready, run the tool using:

./bin/compiler

๐Ÿš€ Features

  • โœ… Supports C, C++, and Python
  • ๐Ÿง  Validates filenames to prevent invalid or reserved names (cross-platform)
  • ๐Ÿ“‚ Automatically detects source files in a predefined input/ directory
  • ๐ŸŽจ Uses colored terminal output for better feedback
  • ๐Ÿ” Exception-safe with detailed error handling
  • โš ๏ธ Single-file compilation only

๐Ÿง‘โ€๐Ÿ’ป What I Learned

Through this project, I gained hands-on experience with:

  • Managing files and directories using std::filesystem
  • Using std::regex to validate filenames and user input
  • Parsing strings with stringstream and getline
  • Implementing platform-independent logic (e.g., path separators)
  • Writing modular C++ code with headers and source files
  • Handling errors safely with try-catch blocks
  • Understanding how different languages are compiled or interpreted

This small project brought together many core C++ concepts and taught me how to design a usable, extensible tool from scratch.


๐Ÿ”ฎ Future Potential & Extensibility

Although currently designed for single-file compilation, the structure makes it easy to extend:

  • ๐Ÿ”ง Add more languages: Java, C#, JavaScript, Go, Rust, etc.
  • ๐Ÿงช Integrate with judge systems: As the execution core for an auto-grader or Online Judge platform
  • ๐Ÿ—ƒ๏ธ Support multi-file builds: By scanning and compiling all relevant .cpp and .h files
  • ๐ŸŒ Add UI or Web Interface: Wrap with a GUI (Qt) or browser front-end
  • ๐Ÿ” Improve security: Replace system() with safer process execution mechanisms

This makes the tool not just a project, but a solid foundation for future software development tooling.


๐Ÿ“Œ AI Usage

GPT-4o is used for:

  • Modular structure and cross-platform design ideas
  • Regex-based filename validation (Windows/Linux safe)
  • Clean command-line prompts and error handling
  • README writing, formatting, and project clarity

About

A command-line tool that compiles and runs program.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published