Skip to content

C Compiler to Linux x64 assembly and to LaserLang written in Java

Notifications You must be signed in to change notification settings

GalHorowitz/CCompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 

Repository files navigation

CCompiler

C Compiler to Linux x64 assembly and to LaserLang written in Java.

About

This is a simple c compiler written in Java. Based on the blog series Writing a C Compiler by Nora Sandler. It currently supports a very small subset of C:

  • Functions
  • Local and Global variables
  • All different types of binary/unary math and logic operators
  • Flow control (Ifs, Loops)
  • Integer types only (The return of void functions is also int for now)

The code quality is not the best, this is an exercise about learning how compilers work.

LaserLang

There is also an option to compile to the esoteric language LaserLang, the option is a boolean variable in the main function. When compiling for LaserLang, you can use the following functions for I/O:

int putchar(int chr);
int putint(int i);
int getint();
  • Note: You must declare the IO functions for them to be included in the generated code.

Usage

Compile the source, and then

java -jar CCompiler.jar filename.c

Use the -d flag for debug output.

About

C Compiler to Linux x64 assembly and to LaserLang written in Java

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages