All Projects → wgtdkp → Wgtcc

wgtdkp / Wgtcc

Licence: mit
A small C11 compiler

Programming Languages

assembly
5116 projects
cpp11
221 projects

Projects that are alternatives of or similar to Wgtcc

Fortran-Tools
Fortran compilers, preprocessors, static analyzers, transpilers, IDEs, build systems, etc.
Stars: ✭ 31 (-94.66%)
Mutual labels:  preprocessor, compilers
Binaryen
Compiler infrastructure and toolchain library for WebAssembly
Stars: ✭ 5,294 (+812.76%)
Mutual labels:  compilers
Compilingtheory
My course design for compiler theory (Visualization).
Stars: ✭ 257 (-55.69%)
Mutual labels:  compilers
Como Lang Ng
como-lang-ng is now ana-lang, located at https://github.com/analang/ana
Stars: ✭ 342 (-41.03%)
Mutual labels:  compilers
Devito
Code generation framework for automated finite difference computation
Stars: ✭ 285 (-50.86%)
Mutual labels:  compilers
Compilers Targeting C
A list of compilers that can generate C code
Stars: ✭ 385 (-33.62%)
Mutual labels:  compilers
cs-resources
Curated Computer Science and Programming Resource Guide
Stars: ✭ 42 (-92.76%)
Mutual labels:  compilers
Css Crush
CSS preprocessor. Written in PHP
Stars: ✭ 539 (-7.07%)
Mutual labels:  preprocessor
Libfsm
DFA regular expression library & friends
Stars: ✭ 512 (-11.72%)
Mutual labels:  compilers
Babel Plugin Css Modules Transform
Extract css class names from required css module files, so we can render it on server.
Stars: ✭ 318 (-45.17%)
Mutual labels:  preprocessor
Kgt
BNF wrangling and railroad diagrams
Stars: ✭ 312 (-46.21%)
Mutual labels:  compilers
Docpad
Empower your website frontends with layouts, meta-data, pre-processors (markdown, jade, coffeescript, etc.), partials, skeletons, file watching, querying, and an amazing plugin system. DocPad will streamline your web development process allowing you to craft powerful static sites quicker than ever before.
Stars: ✭ 3,035 (+423.28%)
Mutual labels:  preprocessor
Simd Visualiser
A tool to graphically visualize SIMD code
Stars: ✭ 459 (-20.86%)
Mutual labels:  compilers
Poststylus
PostCSS adapter for Stylus
Stars: ✭ 279 (-51.9%)
Mutual labels:  preprocessor
Compiladores
Stars: ✭ 535 (-7.76%)
Mutual labels:  compilers
real-world-idris
Malfunction backend for Idris with a FFI to OCaml
Stars: ✭ 26 (-95.52%)
Mutual labels:  compilers
Hellscape
GIMPLE obfuscator for C, C++, Go, ... all supported GCC targets and front-ends that use GIMPLE.
Stars: ✭ 298 (-48.62%)
Mutual labels:  compilers
Suit
Style tools for UI components
Stars: ✭ 3,763 (+548.79%)
Mutual labels:  preprocessor
Yay
Yay is a high level PHP preprocessor
Stars: ✭ 553 (-4.66%)
Mutual labels:  preprocessor
Vim Colortemplate
The Toolkit for Vim Color Scheme Designers!
Stars: ✭ 535 (-7.76%)
Mutual labels:  preprocessor

wgtcc Build Status codecov

A small C11 compiler in C++11.

Environment

  1. x86-64
  2. linux 4.4.0
  3. clang 3.8.0 (or any version supports C++11)

Build

cmake . -Bbuild
cd build && make && make test

Install

make install

Then you can play with the examples:

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

Without Install

Try this:

./wgtcc -no-pie -I../include ../example/heart.c

Notice

As wgtcc doesn't support PIC/PIE, if you are using gcc >= 6.2.0, specify -no-pie explicitly:

wgtcc -no-pie example/heart.c
wgtcc -no-pie 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 written 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. 9c
  6. macro expansion algorithm

Todo

  • [ ] support GNU extensions (e.g. keyword __attribute__)
  • [ ] support variable length array
  • [ ] optimization (e.g. register allocation)
  • [x] support type qualification
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].