Giter Site home page Giter Site logo

compilerproject's Introduction

Decaf Compiler

This project is a java implementation of a compiler translating Decaf language to a certain target (virtual) machine code. The details of the definitions and objectives can be found in DecafProject.pdf. The execution of the virtual machine is also implemented.

No special tool is used in this project and all parts are implemented.

Features

The program may be configured to generate the machine code in one-pass, instead of the default which generate an Intermediate Representation (IR) first. The configuration is an easy code modification.

Lexer

Two implementation:

  • Raw Java code
  • Using jFlex

Capabilities:

  • Handles #include command.
  • Identifies any possible error and does the following:
    • Reports the exact file name and line number where the error occurred.
    • Guesses what went wrong and suggests some corrective measures.
    • By default uses the panic-mode error recovery. The user can disable this feature.

Parser, Semantic Analyzer and Abstract Sytanx Tree

  • The grammar is converted to a L-attributed and LL(1) grammar.
  • On-demand error recovery, which uses panic-mode and a simple phrase-level strategies.
  • A Syntax-directed translation is implemented in a way that IR generation (or the taget machine code depending on the user's choice) is done in one-pass.

IR to machine code module

  • Translates the IR code to the target machine code.

Screenshots

The screenshots can be found in the Overview directory.

To IR Code

Sort

sort This error is due to the fact that the grammar doe not support simultaneous variable definition and assignment.

Semantic

semantic

Semantic 2

semantic2

Scope

scope

Prime

prime

Op

op

Multi-dimensional Array

multDimArray

Recursive Factorial

fac

Exp

exp

Bad Array

badarray

Array

array

To The Machine Code and then Evaluated

Array

array

Array Output

array-output

Exp

exp

Index Out of Bound

indexOutOfBound

Op

op

compilerproject's People

Contributors

ariaadibi avatar

Watchers

 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.