Coder Social home page Coder Social logo

wgtcc's Introduction

wgtcc

a small C11 compiler in C++

PLATFORM

x86-64 only

INSTALL

$ make install # root required
$ make test

then you can play with the examples:

$ wgtcc example/heart.c
$ wgtcc example/chinese.c

GOAL

wgtcc is aimed to implement the full C11 standard with some exceptions:

  1. some features are supported only in grammar level(like keyword register)
  2. features that disgusting me are removed(like default int type without type specifier)
  3. some non standard GNU extensions are supported, but you should not rely on wgtcc of a full supporting

FRONT END

A basic recursive descent parser

BACK END

wgtcc generates code from AST directly. The algorithm is TOSCA(top of stack caching). It is far from generating efficient code, but at least it works and generates code efficently.

MEMORY MANAGEMENT

Through wgtcc was wirtten in C++, i paid no effort for memory management except for a simple memory pool to accelerate allocations. only new is preferred because wgtcc runs fast and exits immediately after finishing parsing and generating code.

REFERENCE

  1. Compilers Principles, Techniques and Tools. second Edition.
  2. N1548, C11 standard draft
  3. 64-ia-32-architectures-software-developer-manual-325462
  4. 8cc
  5. macro expansion algorithm

TODO

  1. support type qualification
  2. support variable length array

wgtcc's People

Contributors

wgtdkp avatar

Watchers

 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.