Giter Site home page Giter Site logo

compojure's Introduction

Compojure

This is an in-progress compiler for a subset of the C language (called the "E" language in this project, which will hopefully resemble C closely once finished), written in Clojure.

This is an application project for CentraleSupélec's compilation course : the compiler was initially meant to be written in OCaml (based on this skeleton), but I was looking for a cool project to perfect my Clojure skills, so I figured I would just re-write it in Clojure.

Progress

  • Lexer and parser (using Instaparse)

  • Translation from AST to E-lang high level representation, and interpreter for this representation (e_interpreter.clj). This interpreter is called by default from the main function :

    $ lein run "main(a) { return a + 1; }" 4
    >> 5
    
  • Translation to CFG (Control Flow Graph) IR, and interpreter for this IR (cfg_interpreter.clj)

  • Dead code detection and elimination

  • Translation to RTL (Register Transfer Language)

  • Translation to RISC-V assembly

Language features

More features will be added once a first working compiler for the initial set of features is achieved.

  • Integer literals and variables
  • Integer arithmetic
  • Variable assignment
  • Print statement
  • Return statement
  • While loops
  • If/else conditionals
  • Subroutines (allow calling other functions from main)
  • String type
  • Arrays
  • Global variables
  • Pointers

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.