johndoe31415 / mcc

Paleoinformatics: C-type language compiler written in Java written in 2006 during a university course

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mcc

mcc is a minimal compiler which three of us, Severin Strobl @severinstrobl, Tobias Preclik @tpreclik and myself developed during a university course "Compilerbau" (Compiler building) in our 5th semester.

It is built from the ground up from the grammar of the language (lexer/parser), generating an AST, generating custom immediate code from the AST, optimizing (variable placement/common subexpression eliminiation etc.) up to a point where it emits assembly code for either i686 (Intel 32 bit) or Power PC. The generated assembly output then can be compiled with gcc. Power PC has never been tested on actual hardware (only on emulators), but Intel assembly was working. On modern gcc versions, some testcases fail, unfortunately.

Usage

Building can simply be done like this:

$ . config
$ make

Then, mcc can be used:

$ ./mcc --arch ia32 -S hallo_welt.S examples/hallo_welt.e

$ gcc -m32 -o hallo_welt hallo_welt.S
/usr/bin/ld: warning: /tmp/cc7uzDQn.o: missing .note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/bin/ld: /tmp/cc7uzDQn.o: warning: relocation in read-only section `.text'
/usr/bin/ld: warning: creating DT_TEXTREL in a PIE

$ ./hallo_welt
Hallo Welt!

Dependencies

As parser generator, mcc uses JLex, an educational parser generator from Cornell university (circa year 2000). For convenience reasons, the generated lexer/parser code (src/Yylex.java and src/Parser.java) have already been generated and checked in.

License

GNU GPL-3.

About

Paleoinformatics: C-type language compiler written in Java written in 2006 during a university course

License:GNU General Public License v3.0


Languages

Language:Java 95.2%Language:Yacc 2.9%Language:Makefile 1.0%Language:Lex 0.9%Language:Shell 0.1%