Inspiration

Our inspiration was just the urge to learn and try new things. We wanted to attempt something for our team that neither of us have done before not only as a challenge, but our own personal growth.

What it does

It takes a source code that is a subset of the C language and compiles it to our simplified bytecode. You can then run it with our program that run the instructions line by line.

How we built it

We looked into many different tutorials and papers on how to build compilers. (Notably: http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf) We also applied many of the skills learned in CECS 329 to this project. We created a context free grammar for our specific subset of C written in a variation to the Extended Backus-Naur Form. This gave us a blueprint for our functions and ensured edge cases were covered.

Challenges we ran into

  • When doing lexical analysis we ran into a small bit of issues with choosing which token we wanted and which one we didn't care about
  • While doing parsing analysis and semantic analysis, we had trouble enforcing certain constraints. For example, enforcing that else statements can only come after if statements.
  • Our original plan of compiling C to Assembly had to be scrapped because of our lack of knowledge in Assembly. We were unable to write code to Assembly.

Accomplishments that we're proud of

  • Our compiler is able to generate a bytecode
  • We are able to run the bytecode
  • We can compile the Fibonacci function into bytecode and have it run correctly

What we learned

  • We learned about the process of building a compiler. Going through the steps of lexical analysis, parsing, code generation, and more.
  • We also learned about abstract syntax tree and how that can be used to bridge the source and target language.

What's next for The Combiler

  • The next step for us is to compile to assembly rather than bytecode
  • After that, program optimization during compilation would be a great next step for our learning

Built With

Share this project:

Updates