Custom built compiler using Yacc and Lex.
- Interger Literals, Variables
- Assignment Statements
- Arithemtic Operators (+, -, *, /, ^, -(unary minus))
- P
- Boolean Literals, Variables
- Assignment Statements
- Relational Operators (<, <=, ==, >=, >, !=)
- Boolean Operators (!, &&, ||)
- NOTE: Parentheses do not work - we when through it in office hours can could not figure out why
- read(comma delimted list of variables)
- read(x, y, z)
- 1 (true), and 0 (false) can be input for boolean variables
- print(comma delimted list of Expressions);
- print(2x, x^3(zw), abc/xyz, c)
- printlines(expression)
- print expression number of newlines
- printString("Literal String")
- if statements including optional else
- while loops
- 1 Dimensional Arrays
- 2 Dimensional Arrays
- void parameterless functions
Clone the project
git clone https://github.com/Mbiwersi/C-based-Compiler
Go to the project directory
cd my-project
Generate supporting yacc files
yacc -d ExprEval.y
Generate supporting lex files
lex lex1.l
Compile Files
cc -o comp lex.yy.c y.tab.c SymTab.c Semantics.c CodeGen.c IOMngr.c main.c
Execute the Program
./comp source.txt listing.lst asmCode.asm
Clone the project
git clone https://github.com/Mbiwersi/C-based-Compiler
Go to the project directory
cd my-project
Generate supporting yacc files
bison -dy ExprEval.y
Generate supporting lex files
lex lex1.l
Compile Files
gcc -o comp lex.yy.c y.tab.c SymTab.c Semantics.c CodeGen.c IOMngr.c main.c
Execute the Program
./comp source.txt listing.lst asmCode.asm