https://github.com/vijayphoenix/compiler-written-in-haskell
A Turing complete language 😉
https://github.com/vijayphoenix/compiler-written-in-haskell
compiler haskell iith jit-compiler just-in-time language llvm llvm-hs parsing popl toy-compiler toy-language
Last synced: about 2 months ago
JSON representation
A Turing complete language 😉
- Host: GitHub
- URL: https://github.com/vijayphoenix/compiler-written-in-haskell
- Owner: vijayphoenix
- License: mit
- Created: 2019-04-15T08:36:52.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-10-03T18:59:13.000Z (over 4 years ago)
- Last Synced: 2025-04-17T04:19:32.009Z (about 2 months ago)
- Topics: compiler, haskell, iith, jit-compiler, just-in-time, language, llvm, llvm-hs, parsing, popl, toy-compiler, toy-language
- Language: Haskell
- Homepage:
- Size: 36.1 MB
- Stars: 42
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://travis-ci.com/vijayphoenix/Compiler-written-in-Haskell)
[](https://circleci.com/gh/vijayphoenix/Compiler-written-in-Haskell/tree/master)# Implementing a JIT Compiled Language with Haskell
## About
The project aimed to implement a simple procedural language.
We named it **HASKULL** :-)
The frontend is written in Haskell and the backend it managed LLVM-hs-pure package.
The project extensively uses Monads, State Monads, Applicative functors and Transformers.### Built With
You will need GHC 7.8 or newer as well as LLVM 4.0.
### Installation
Clone the repository:
```
git clone https://github.com/vijayphoenix/Compiler-written-in-Haskell.git
```Browse to the directory where all the files of this repository are located.
Run the following command to build the project.
```
stack build
```
# UsageRun the following command to get an interactive console.
```
stack repl
```
Type "main" in the interactive console.Write any code using the following Syntax rules.
```
Syntax rules:
[A] means optional arg. of type A .All the symbol starting with lower-case letter are terminal(lexer units).
All the operators are left associativeCommand = Expr ;
Expr : DeclarationStmt| FuncCallStmt | LiteralStmt | ifthenStmt | (Expr)DeclarationStmt : ExternDecl
ExternDecl : extern Name([ArgList]) : Type
Type : int
VList: Name[, VList]FuncCallStmt : Call
Call : Name ( [Args] )BinOpCallStmt : BinOpCall
BinOpCall : Expr Op ExprOp : + | - | * | / | ; | <
reserved keywords: int char def extern string if then else
Args : Expr[, Args]LiteralStmt : IntLiteral
IntLiteral : integerName : ident
ArgList : Type Name[, ArgList]Func : def Name([ArgList]) : Type { Command-list }
Command-list = Command [Command-list]Command = Expr ;
```
Some sample example functions are provided in examples.txt file.
For more insight on the language grammar, refer to Language.hs, AST.hs files.### Documentation
This project is documented under [Haddock](https://www.haskell.org/haddock/#Documentation) Documentation
To generate documentation run:
```
stack haddock
```### Authors
* [**Vijay Tadikamalla**](https://github.com/vijayphoenix)
* [**Anjani Kumar**](https://github.com/anjani-1)
* [**Anupam Saini**](https://github.com/anupamsaini98)
* [**Yogesh Singh**](https://github.com/yo5sh)#### License
* [LICENSE](LICENSE)#### Acknowledgments
* [Haskell LLVM JIT Compiler Tutorial](http://www.stephendiehl.com/llvm)