Giter VIP home page Giter VIP logo

decaff-compiler's Introduction

Decaf compiler

Repo Structure

  • ast.h: It contains the ast structure of a decaf program. I have made passes like printing the ast and the code generation in llvm using the visitor design pattern.
  • BlockTable.h: It contains a class to store all the block variables in the local scope
  • compiler.l: This is the lex file and it generates the lexical analyzer of this language
  • compiler.y: This file if the parser generator for the decaf language, and the grammar of the language has been specified in this file
  • Visitor.h: It contains the definitions of all the visitors, which are neccessary for a pass to be run on it
  • PrintVisitor.cpp: This is a pass which prints the ast that has been generated after running the compiler on a decaff program
  • CodeGenVisitor.h: This is a pass which generates the llvm IR, which can be furthur compiled using lli or clang and an executable can be generated
  • main_codegen_visitor.cpp: This is the main file to run the CodeGenVisitor pass on the generated ast
  • main_print_visitor.cpp: This is the main file to run the PrintVisitor pass on the generated ast
  • sample_programs: It contains some sample decaf programs to test the compiler

Running the executable

For IR Generation

To build the front end

make TYPE=main_codegen_visitor.cpp 

To obtain the IR

./compiler <input_file> > <output_file>

To convert the IR into executable

clang-3.6 <output_file>

To run the executable

./a.out

For Print Visitor

make TYPE=main_print_visitor.cpp

To obtain the printed AST

./compiler <input_file>

Description

  • This is llvm frontend for the decaf programming language. The intermediate representation is generated on the standard output. If any errors are detected, the error is thrown on the stderr.
  • The things still to be implemented are the continue statement, the break statement, and the error handling on detection of an error.

decaff-compiler's People

Contributors

anishgg avatar

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.