GithubHelp home page GithubHelp logo

bartvandewoestyne / modern-compiler-implementation-in-c Goto Github PK

View Code? Open in Web Editor NEW
27.0 4.0 5.0 260 KB

An unfinished implementation of the Tiger compiler.

Makefile 6.06% C 90.71% Shell 0.54% C++ 2.69%

modern-compiler-implementation-in-c's Introduction

My implementation of the Tiger compiler from the book

  Modern Compiler Implementation in C
  Andrew W. Appel
  Cambridge University Press
  ISBN 0-521-60765-5

This work is not finished yet.  From time to time, I hack on it.

I was not quite sure in what C-standard or dialect I was going to write my
code, so I did some investigations...

From the inside of the book, we have:

  First published 1998
  Reprinted with corrections, 1999
  First paperback edition 2004

Also, the code from Chapter 1 defines its own TRUE and FALSE in util.h, and
since C99 has true and false macros in stdbool.h, I think we can conclude that
the book's code is *not* C99.

Finally, in Chapter 2, the strdup function is used.  This function is neither
C90 nor C99... so the code from the book is probably some pre-C90 dialect...

I am therefore simply compiling it with gcc without any -std option.


Some other remarks:
-------------------

* In the post

    https://groups.google.com/d/msg/comp.compilers/QYrE4LvCcCE/fxLyAJfxDocJ

  on comp.compilers it is written that the book was originally written by
  Appel in ML, and then translated to C and Java, so the C and Java are not
  great examples of how to code in those languages (the Java version uses few
  OO programming techniques).

* The code often makes use of a union paired with a discrete value that
  indicates the active member of the union.  This is called a 'discriminated
  union' or 'tagged union'.  The discrete value is called a discriminator or
  tag.  See also

    http://www.drdobbs.com/cpp/discriminated-unions/240009296
    http://en.wikipedia.org/wiki/Tagged_union

modern-compiler-implementation-in-c's People

Contributors

bartvandewoestyne 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

Watchers

 avatar  avatar  avatar  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.