A compiler for the Jinx programming language, built using LLVM. This project follows the structure and concepts from the LLVM Kaleidoscope Tutorial.
- Introduction
- Features
- Prerequisites
- Installation
- Usage
- Examples
- Contributing
- License
- Acknowledgments
The Jinx Compiler is an experimental language frontend for LLVM, aiming to explore compiler design and language implementation. It serves as a learning platform and a starting point for anyone interested in building programming languages.
- Lexical Analysis: Tokenizes Jinx source code.
- Parsing: Generates an Abstract Syntax Tree (AST) from tokens.
- Semantic Analysis: Performs type checking and scope resolution.
- Code Generation: Converts the AST into LLVM Intermediate Representation (IR).
- JIT Compilation: Just-In-Time compiles and executes code.
- Extensible Design: Easily add new language features.
- LLVM (version 10 or higher)
- C++ Compiler (supporting C++17 or higher)
- CMake (version 3.10 or higher)
- Git (for cloning the repository)
-
Clone the Repository
git clone https://github.com/yourusername/jinx-compiler.git cd jinx-compiler
-
Set Up LLVM
Ensure that LLVM is installed and the
llvm-config
executable is in your PATH. -
Build the Compiler
mkdir build cd build cmake .. make
-
REPL Mode
Start the interactive Read-Eval-Print Loop (REPL):
./jinx
-
Script Mode
Run a Jinx script file:
./jinx path/to/script.jx
Hello World
print("Hello, World!");
Factorial Function
def factorial(n)
if n <= 1 then
1
else
n * factorial(n - 1);
print(factorial(5)); // Output: 120
Contributions are welcome! Please follow these steps:
-
Fork the Repository
Click the "Fork" button at the top right of the repository page.
-
Create a Feature Branch
git checkout -b feature/YourFeature
-
Commit Your Changes
git commit -am 'Add YourFeature'
-
Push to Your Fork
git push origin feature/YourFeature
-
Submit a Pull Request
Open a pull request against the
main
branch of this repository.
This project is licensed under the MIT License. See the LICENSE file for details.
- LLVM Project for providing a robust compiler infrastructure.
- LLVM Kaleidoscope Tutorial for inspiration and guidance.
- Contributors and open-source community for their support.