|
1 | | -# Implementing a JIT Compiled Language with Haskell |
| 1 | +[](https://circleci.com/gh/IITH-SBJoshi/haskell-11/tree/master) |
| 2 | + |
| 3 | +# Implementing a JIT Compiled Language with Haskell |
2 | 4 |
|
3 | 5 | ## About |
4 | 6 |
|
| 7 | +The aim of the project was to implement a simple procedural language. |
| 8 | +We named it **HASKULL** :-) |
| 9 | +The frontend is written in Haskell and the backend it managed LLVM-hs-pure package. |
| 10 | +The project extensively uses Monads, State Monads, Applicative functors and Transformers. |
| 11 | + |
5 | 12 | ### Built With |
6 | 13 |
|
7 | | -### Installing |
| 14 | +You will need GHC 7.8 or newer as well as LLVM 4.0. |
| 15 | + |
| 16 | +### Installation |
| 17 | + |
| 18 | +Clone the repository: |
| 19 | + |
| 20 | +``` |
| 21 | +git clone "https://github.com/IITH-SBJoshi/haskell-11.git" |
| 22 | +``` |
| 23 | + |
| 24 | +Browse to the directory where all the files of this repository are located. |
| 25 | + |
| 26 | +Run the following command to build the project. |
| 27 | + |
| 28 | +``` |
| 29 | +stack build |
| 30 | +``` |
| 31 | +# Usage |
| 32 | + |
| 33 | +Run the following command to get an interactive console. |
| 34 | + |
| 35 | +``` |
| 36 | +stack repl |
| 37 | +``` |
| 38 | +Type "main" in the interactive console. |
| 39 | + |
| 40 | +Write any code using following Syntax rules |
| 41 | + |
| 42 | +``` |
| 43 | +Syntax rules: |
| 44 | +[A] means optional arg. of type A . |
| 45 | +
|
| 46 | +All the symbol starting with lower-case letter are terminal(lexer units). |
| 47 | +All the operators are left associative |
| 48 | +
|
| 49 | +Command = Expr ; |
| 50 | +Expr : DeclarationStmt | FuncCallStmt | LiteralStmt | Var | ifthenStmt | (Expr) |
| 51 | +
|
| 52 | +DeclarationStmt : ExternDecl | VarDecl |
| 53 | +
|
| 54 | +ExternDecl : extern Name([ArgList]) : Type |
| 55 | +VarDecl : Type VList |
| 56 | +
|
| 57 | +Type : int | string |
| 58 | +VList: Name[, VList] |
| 59 | +
|
| 60 | +FuncCallStmt : Call |
| 61 | +Call : Name ( [Args] ) |
| 62 | +
|
| 63 | +BinOpCallStmt : BinOpCall |
| 64 | +BinOpCall : Expr Op Expr |
| 65 | +
|
| 66 | +Op : + | - | * | / | ; | = | < |
| 67 | +reserved keywords: int char def extern string if then else |
| 68 | +Args : Expr[, Args] |
| 69 | +
|
| 70 | +LiteralStmt : StrLiteral | IntLiteral |
| 71 | +IntLiteral : integer |
| 72 | +StrLiteral : string |
| 73 | +
|
| 74 | +Name : ident |
| 75 | +ArgList : Type Name[, ArgList] |
| 76 | +
|
| 77 | +Func : def Name([ArgList]) : Type { Command-list } |
| 78 | +Command-list = Command [Command-list] |
| 79 | +
|
| 80 | +Command = Expr ; |
| 81 | +``` |
| 82 | +For more insight on the language grammer, refer to Language.hs, Lexer.hs, Parser.hs files. |
8 | 83 |
|
9 | | -On Linux |
10 | 84 |
|
11 | 85 | ### Documentation |
12 | 86 |
|
13 | 87 | This project is documented under [Haddock](https://www.haskell.org/haddock/#Documentation) Documentation |
14 | 88 |
|
| 89 | +To generate documentation run: |
| 90 | + |
| 91 | +``` |
| 92 | +stack haddock |
| 93 | +``` |
| 94 | + |
15 | 95 | ### Authors |
16 | 96 |
|
17 | | -* [**Vijay Tadikamalla**](https://github.com/vijayphoenix) |
| 97 | +* [**Vijay Tadikamalla**](https://github.com/vijayphoenix) |
| 98 | +* [**Anjani Kumar**](https://github.com/anjani-1) |
| 99 | +* [**Anupam Saini**](https://github.com/anupamsaini98) |
| 100 | +* [**Yogesh Singh**](https://github.com/yo5sh) |
18 | 101 |
|
19 | 102 | #### License |
| 103 | +* [LICENSE](https://github.com/IITH-SBJoshi/haskell-11/blob/master/LICENSE) |
20 | 104 |
|
21 | 105 | #### Acknowledgments |
22 | | -* [Haskell LLVM JIT Compiler Tutorial](http://www.stephendiehl.com/llvm) |
| 106 | +* [Haskell LLVM JIT Compiler Tutorial](http://www.stephendiehl.com/llvm) |
0 commit comments