Skip to content

TsukudaniVanish/cc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

cc

C/C++ CI
cc is a subset of c compiler. It will cover the c89 syntax in th future. This product is developed for my study of computer science. Pull requests which are related to language implementation will be declined since I want to study implementing features and do that by my self. Any issues are welcome and will help me for developing this project. Thank you for your understanding!

covered language functionalities

type

  • void
  • char
  • int
  • unsigned
  • struct
  • union
  • enum

flow operation, statement

  • if
  • else
  • { ... }
  • switch
  • while
  • for
  • continue
  • break
  • return

preprocessor

  • #define
  • #if ... #endif

other keyword

  • typedef
  • sizeof

code/

test/

test.h

A test header file for test.c

test.c

A test file for application. This file is not used to build cc.

backend/

error_point.c

All error point logics are controlled here.

file.c

A file reader and an include path finder.

cc.h

A header file which all used functions are declared in. Also, briefs of those functions are written here.

Token.c

New token functions which make new tokens and token utilities

Node.c

New node functions which make new nodes for abstract syntax tree

Vector.c

This file serves vector utilities.

Map.c

Hash map utilities

String.c

String utilities such as strlen, strncmp, strncpy in string.h.

unittest.c

Functions for unit test.

tokenize.c

A tokenizer

main.c

A main function are written in this file.

parse.c

Parsing functions.

codegenerator.c

Generator functions which convert an abstract syntax tree into assembly codes.

todo

  • refactoring/ remove include standard library
  • allow type cast in a global declaration
  • add %
  • add unsigned long
  • add macro operator #, ##
  • fix the extern static variables code generation
  • add va-arg function declaration
  • add include file path find algorithm
  • add #ifndef, #ifdef
  • add #elif #else
  • add a character literal ''
  • add type cast
  • add long and long int
  • add ? :
  • add typedef
  • sizeof can accept type-keyword, type alias
  • add do{...}while(...)
  • refactoring preprocessor (especially macro_expansion)
  • add storage class specifiers (static, extern)
  • add #include to preprocessor

coding policy

memory management

For simplicity, we will not manage memories in cc codes. We allocate memories to pointers but will not free memories within the compiler life cycle. Don't use "free" before changing this policy.

Reference

Rui Ueyama,低レイヤを知りたい人のためのCコンパイラ作成入門,2020-03-16,https://www.sigbus.info/compilerbook ISO/IEC 9899:2011 - Information technology - Programming languages - C
draft of standard above ,last edited 2012-Nov-11 20:09:34,https://port70.net/~nsz/c/c11/n1570.html

About

cc is my c compiler making project.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published