A C/C++ compiler with lexical analysis built for educational purposes, demonstrating the key phases of compilation: lexical analysis, syntax analysis, and semantic analysis.
- Web-based interface for writing and compiling C/C++ code
- Visual representation of compiler phases
- Lexical analysis with token generation
- Syntax analysis with parse table generation
- Interactive terminal for program I/O
- Windows-only environment support
nano-cc-compiler/
├── client/ # React frontend
│ ├── src/ # Source code
│ ├── public/ # Static assets
│ └── package.json # Frontend dependencies
├── server/ # Node.js backend
│ ├── lexical/ # Lexical analysis implementation
│ ├── syntax/ # Syntax analysis implementation
| ├── semantic/ # Semantic analysis implementation
│ ├── compiler.bat # Windows batch script for compilation
│ ├── index.js # Express server
│ └── package.json # Backend dependencies
├── start.bat # Windows startup script
└── package.json # Root package.json for running both client and server
- Windows operating system
- Node.js (v14 or higher)
- npm (v6 or higher)
- GCC compiler (for actually compiling C/C++ code)
- lex (for lexical analysis)
- win_bison (for syntax and semantic analysis)
- Graphviz (for creating graphs)
- Git Bash (for running shell scripts)
-
Clone the repository:
git clone https://github.com/SanchitNegi177/Nano-CC-Compiler.git cd nano-cc-compiler -
Install dependencies:
npm run install:allThis will install dependencies for both client and server.
-
Run the development server:
npm run devOr simply double-click the
start.batfile. -
Open your browser and navigate to
http://localhost:3000
For Windows users:
- The application uses a .bat file for running the compiler process
- Make sure you have GCC installed and added to your PATH
- Make sure you have renamed your 'win_flex.exe' to 'lex.exe'
- Ensure Git Bash is installed (usually comes with Git for Windows)
- Install win_bison for Windows (not the Unix version)
- User writes C/C++ code in the editor
- Code is sent to the Node.js backend
- Backend processes the code through multiple phases:
- Lexical analysis (token generation)
- Syntax analysis (parse tree generation)
- Semantic analysis (Verified AST)
- Results are sent back to the frontend and displayed
- The compiled program can be executed and its output viewed in the terminal
- Implement full Lex/Yacc integration
- Support for more C/C++ language features
- Better error handling and debugging tools
- Integration with LLVM for better code generation
- Support for multiple compiler backends
This project is licensed under the ISC License.