Skip to content

8l/ucc-c-compiler

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A C Compiler written in C


Requirements
============

as (I use gnu as, but any should be fine)
ld (any form should be fine)

Obviously you need a compiler to compile this compiler with.

Standard system include files are supported
- barring a preprocessor bug with multiple function macro expansions on the same line (e.g. glibc's tgmath.h)
- barring __asm__ statements (feature/asm)

System libraries are fully supported, including ABI compatability with things like va_list.


Compiling (the compiler)
========================

./configure [--as=path/to/as]
make


Compiling C files
=================

POSIX 'cc' standard arguments plus a few extra.
No make install target yet, ucc uses libaries from the usual place.


Major C-Features Todo
=====================

- by-value argument passing for structure/union types (feature/1st-class-struct-args)
- long long types on 32-bit archs
- long-double type
- complex types (_Complex)


Examples
========

./ucc -o hello hello.c
- preprocess, compile, assemble and link hello.c into hello

./ucc -o- -S test.c
- output assembly code for test.c

./ucc -o- -S -Xprint test.c
- show the abstract parse tree with type annotation and stack offsets, etc

./ucc -c test.c
- (preprocess) compile and assemble test.c -> test.o

./ucc -c test.s
- assemble test.s -> test.o
(preprocessing and compilation are skipped)

./ucc -fenglish -Xprint -o- test.c
- (-fenglish) show the abstract parse tree with output decls in english
e.g.:
	int *(*const (*x)(void))(int);
becomes:
	"x": pointer to function(taking no arguments) returning const pointer to function(int) returning pointer to int

./ucc test.c a.o -o out b.a
- preprocess + compile test.c, and link with a.o and b.a to form the executable out

./ucc a.o b.c -E
- preprocess b.c - a.o is ignored since it's not linked with

About

A simple C compiler - check the experimental branch(es)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 96.3%
  • Perl 1.7%
  • Makefile 0.9%
  • C++ 0.4%
  • Shell 0.3%
  • Assembly 0.3%
  • Objective-C 0.1%