Skip to content

byanofsky/simple-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

22 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simple-compiler

A simple compiler for a simple programming language.

This project was an exercise to better understand compilers and programming language design.

I utilized ChatGPT as a programming partner.

Language

Currently, the language only supports the following:

  • Integer data type only
  • Variable assignment
  • Addition and subtraction operations
  • Print operation

Example program

var1 = 5 + 6;
var2 = 2 - 1;
var3 = var1 - var2;
print(var3);

// Prints 10

Getting Started

Build the compiler:

make compiler

Compile a program:

./compiler sample_program.txt sample_program

Run the program:

./sample_program

Note: a temporary file called temp.ll will output to the current directory. This can be safely deleted.

Limitations

The LLVM IR target is hardcoded as arm64-apple-macosx12.0.0.

So I suspect this may have trouble running on other machines.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published