Giter VIP home page Giter VIP logo

compiler's Introduction

compiler

Compiler Construction labs:

The descriptions, and percentages are made up by me. The three labs are worth 45% so it's my prediction.

  1. Project 1 (15%): Lexical analysis, Top-down syntax analysis in HACS (v0.9.0)
  2. Project 2a (10%): Outling Syntax-directed translation (SDT), Name analysis, Type analysis
  3. Project 2b (5%): Implementing 2a into HACS (v0.9.5)
  4. Project 3 (15%): Direct code generator - ARM32 assembly subset

Compiler Construction homework: - There are 11 homeworks that I have done. - https://github.com/AbhiAgarwal/classes/tree/master/Compiler%20Construction

There is a Sublime Text page for HACS: - https://github.com/tpalsulich/hacs_sublime_text_theme

Sample code for Project 3

function int div(int nominator, int divisor) {
  // Extract sign of result.
  var int sign;
  sign = 1;
  if (nominator < 0) {
    nominator = -nominator;
    sign = - sign;
  }
  if (divisor < 0) {
    divisor = -divisor;
    sign = -sign;
  }

  // Accumulate result.
  var int result;
  result = 0;

  // The highest value that we cannot safely multiply by 2 is 2^30
  var int halfmax;
  halfmax = 1073741824;

  // Find result by binary long division.
  while (nominator >= divisor) {

    // Find largest factor = 2^n such that factor*divisor <= nominator
    var int factor;
    var int product; // factor*divisor
    factor = 1;
    product = divisor;
    while (product < halfmax && product*2 <= nominator) {
      factor = factor*2;
      product = product*2;
    }
    
    // Record finding in result and reduce problem.
    nominator = nominator - product;
    result = result + factor;
  }
  
  return sign * result;
}

compiler's People

Contributors

abhiagarwal avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

compiler's Issues

Definition 2.2: How to even start?

2.2 Definition. The Expression non-terminal of JST is either a Literal or an Operation. A Literal is either one of the following:

the tokens Integer or String;
an object literal {k1:Literal1, . . . ,kn:Literaln} for n ≥ 1 with each key ki an Identifier (also called “field name”).

done!!

Wrong: space

correct this:

space [ \t\f\r\n] | nested "/*" "*/" | "//" .* ;

Definition 2.4: if .. else ..

| ⟦ if ( ⟨Expression⟩ ) (Statement) ; ⟧

To add else is it:

| ⟦ if ( ⟨Expression⟩ ) ⟨Statement⟩ ; ⟧
| ⟦ if ( ⟨Expression⟩ ) ⟨Statement⟩ else ⟨Statement⟩ ; ⟧

or ⟦ if ( ⟨Expression⟩ ) (⟨Statement⟩ | ⟨Statement⟩ else ⟨Statement⟩) ; ⟧

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.