Code Compiler is a web-based code editor and compiler that allows users to write, edit, and execute code in multiple programming languages directly from their browser. The application is built using React and integrates the Ace Editor for a rich text-editing experience with syntax highlighting, customizable themes, and other features.
- Multi-Language Support: Supports Python, Java, and C/C++.
- Syntax Highlighting: Provided by Ace Editor, with support for various programming languages.
- Customizable Editor: Adjust font size, theme, and language mode.
- Code Execution: Send code to a backend server to execute and return the results.
- Standard Input: Accept user input for programs requiring stdin.
- Output Display: Shows the output, errors, or status of the executed code.
- React: For building the user interface.
- Ace Editor: As the code editor with syntax highlighting and other advanced features.
- Fetch API: To communicate with a backend server for code execution.
- CSS: Custom styling for the application.
-
Clone the repository:
git clone https://github.com/yourusername/code-compiler.git cd code-compiler
-
Install dependencies:
npm install
-
Run the application:
npm start
-
The application will be available at
http://localhost:3000
.
- Write Code: Use the code editor to write your code. Select the desired programming language from the dropdown menu.
- Provide Input: If your code requires standard input, enter it in the "Standard Input" field.
- Run Code: Click the "Run" button to execute your code. The output or any errors will be displayed in the "Output" section.
- Themes: The editor uses the "Monokai" theme by default, but this can be easily changed by importing a different theme from
ace-builds
. - Language Modes: Supports Python, Java, and C/C++. Additional languages can be added by importing the respective mode from
ace-builds
. - Autocompletion: Autocompletion is currently disabled but can be enabled by uncommenting the respective lines in the code.
Check this repo if you need backend server : https://github.com/NaheedRayan/code-execution-engine
The runCode
function in CodeRunner.js
sends the code to a backend server at http://localhost:8080/submit
. You need to implement or configure this server to handle the code execution requests and return the results.
The application polls the backend server for the status of the execution and updates the output accordingly. This is particularly useful for long-running processes.
- src/components/CodeRunner.js: Main React component for the code editor and runner.
- src/components/CodeRunner.css: CSS styles for the components.
- src/App.js: Main application file rendering the
CodeRunner
component.
Contributions are welcome! Feel free to submit a pull request or open an issue to discuss improvements or bugs.
This project is licensed under the MIT License. See the LICENSE file for details.
For any inquiries, please reach out via [email protected].