ARM C Compiler (ACC)

Information about the ARM C Compiler (ACC)

ACC is a pet project with the purpose of improving my knowledge of three topics. The C language, compilers and the ARM assembly. I think this is a good exercise to go deep into both topics.

The ACC is a LALR(1) parser, that means it is a Look-Ahead Left-to-Right parser.

The current Grammar of the ACC is the following:

S -> int main "(" ")" "{" E "}"
E -> return I;
     | if "(" B ")" "{" E "}"
     | if "(" B ")" "{" E "}" else "{" E "}"
I -> [0-9]+
B -> I < I
     | I <= I
     | I == I
     | I >= I
     | I > I
     | ! B
     | "(" B ")"
   

Future work for the project

  1. Main function
  2. Return statement
  3. Int values
  4. Boolean operations
  5. Conditionals
  6. Variable (int)
  7. Addition and substraction operations
  8. Multiplication and division operations
  9. Comments
  10. Functions
  11. String
  12. Array
  13. Pointer
  14. Struct
  15. Loop
  16. Include
  17. ...
  18. Self-contained Compiler

Example of the usage of the ACC

C code:

Assembly generated: