Skip to content
C Compiler by Go
Branch: master
Clone or download
Latest commit 51e75d4 Oct 9, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
sample Reduce diff Aug 14, 2018
test port a63fbb1 Oct 9, 2018
.gitignore Merge commit '13bddbc3b10122443fd428c1b98f689e44bfada8' Aug 5, 2018
8cc.h show column number on error Sep 26, 2018
LICENSE copied the latest LICENSE Jul 6, 2018
Makefile separate expect and expect_string function and compile it by gcc Sep 4, 2018
MakefileGo port 4dcd568 Oct 2, 2018
README.md update README Jul 14, 2018
TODO Rename. ctype.size -> ctype.len for array Jul 9, 2018
adapter.go port 238daf3 Oct 3, 2018
asrun show gas only with -v option Jun 30, 2018
bothtest.sh
cpp.c port a63fbb1 Oct 9, 2018
cpp.go fix include path Oct 9, 2018
crun
ctest.sh 'make test' covers test/*.c Jul 1, 2018
ctestone.sh helper script to run a single c test Sep 21, 2018
debug.c add short type Sep 23, 2018
debug.go port 672e47e Oct 4, 2018
dict.c fix bol Sep 24, 2018
dict.go port bee1f8c Oct 4, 2018
dict.h fix bol Sep 24, 2018
docker-test.sh enable test by a single docker run command Apr 30, 2018
f rename script to-func -> f Jun 23, 2018
gen.c add short type Sep 23, 2018
gen.go port 672e47e Oct 4, 2018
gorun port 4dcd568 Oct 2, 2018
gotest.sh port eb217d1 Sep 27, 2018
header.go port 6161a69 Oct 6, 2018
lex.c Refactor: invert true/false Sep 26, 2018
lex.go port f6e1ca0 Oct 6, 2018
list.c Enable to include <header.h> Sep 17, 2018
list.go port b9f7b0f Oct 1, 2018
list.h Enable to include <header.h> Sep 17, 2018
main.c ast_to_string, token_to_string -> a2s,t2s Aug 23, 2018
main.go port 3e14df0 Oct 2, 2018
parse.c port a63fbb1 Oct 9, 2018
parse.go port 1233d17 Oct 9, 2018
string.c Introduce format function and replace string_appendf with it Sep 18, 2018
string.go port 4dcd568 Oct 2, 2018
test.sh Reduce diff Aug 15, 2018
util.c Reduce diff Sep 19, 2018
util.go port 661fb68 Oct 3, 2018
util.h add TTYPE_CHAR Sep 3, 2018
utiltest.c Impl list_get() Sep 3, 2018

README.md

8cc.go C Compiler

8cc.go is a C Compiler written in Go. It's a port of 8cc (https://github.com/rui314/8cc)

Author

DQNEO

( Originally from Rui Ueyama rui314@gmail.com )

Usage

The output assembly code can only be run on Linux.

If you use other platforms, I would recomment Docker to run it.

$ docker run -it --rm -v `pwd`:/mnt  dqneo/ubuntu-build-essential:go bash
root@62b0d706a586:/mnt# echo 'int main(){printf("%s\n","hello world");}' |./gorun|./asrun
hello world

What kind of syntax does it support ?

  • if/else
  • for
  • binary operators (+-/* & |)
  • logical operators (&&, ||)
  • ternary operator (?:)
  • declaration of functions
  • function call
  • assign to local variables
  • assign to global variables
  • primitiv data types (int, char, char *, float, double)
  • composite data types (array, struct, union, pointer)
  • arithmetic of pointer
  • dereference of pointer

Test

$ docker run -it --rm -v `pwd`:/mnt  dqneo/ubuntu-build-essential:go bash
root@62b0d706a586:/# cd /mnt/
root@62b0d706a586:/mnt# ./gotest.sh

LICENSE

MIT License

You can’t perform that action at this time.