GithubHelp home page GithubHelp logo

vijayphoenix / compiler-written-in-haskell Goto Github PK

View Code? Open in Web Editor NEW
40.0 2.0 3.0 36.93 MB

A Turing complete language ๐Ÿ˜‰

License: MIT License

Haskell 100.00%
haskell parsing compiler llvm-hs llvm just-in-time jit-compiler toy-language toy-compiler iith popl language

compiler-written-in-haskell's Introduction

Build Status CircleCI

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 

Usage

Run 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 associative

Command = 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 Expr 

Op : + | - | * | / | ; | <
reserved keywords: int char def extern string if then else
Args : Expr[, Args]

LiteralStmt : IntLiteral 
IntLiteral  : integer

Name : 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 Documentation

To generate documentation run:

stack haddock

Authors

License

Acknowledgments

compiler-written-in-haskell's People

Contributors

vijayphoenix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

compiler-written-in-haskell's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.