Skip to content

Latest commit

 

History

History
63 lines (51 loc) · 1.76 KB

README.md

File metadata and controls

63 lines (51 loc) · 1.76 KB

C-Compiler

I have implemented a C compiler using Flex and Bison as tokenizer and parser. This compiler gets a C language program file as input and provides a MIPS assembly output file. You can also run MIPS output file using QtSpim simulator.

Usage guide

Requirements

  • Flex
  • Bison

Flex and Bison are tools for building programs that handle structured input. They were originally tools for building compilers, but they have proven to be useful in many other areas.

You can get and install Flex & Bison tools using the below commands:

sudo apt-get update
sudo apt-get install flex
sudo apt-get install bison

Related Links

Step 1: Download tokenizer.l & parser.y Files

You can clone codes using the below command:

git clone https://github.com/SaraBaradaran/C-Compiler

Step 2: Compile & Run Files

flex tokenizer.l
bison -d parser.y
gcc parser.tab.c lex.yy.c -o compiler

Step 3: Compile Your C Program Using My Compiler

Finally, you can compile your C program using the below command:

./compiler input.c output.asm