Problem Statement: Build a basic Rust compiler using Lex and Yacc
The compiler performs the following tasks:
- Lexical Analysis
- Symbol Table Generation
- Syntax Analysis
- Semantic Analysis
- Error Detection
- Intermediate Code Generation
- Code Optimization
This project uses lex
and yacc
, and also requires gcc
and python3
to be installed
sudo apt-get install -y flex byacc bison
Or use the Dockerfile
instead to run the application in a container:
docker image build -t lex-yacc:latest .
docker container run --name cdproject -it lex-yacc:latest
cd phase\ 1
Using make
:
make parse
Or compile each file individually:
flex parser.l
yacc parser.y
gcc y.tab.c -lfl -w
./a.out test.rs
cd phase\ 2
To Generate ICG:
make parse
Or compile each file individually:
flex parser-v2.l
yacc parser-v2.y
gcc y.tab.c -lfl -w
./a.out test.rs
To optimize ICG code:
make optimize
Or
python3 code_optimizer.py icg.txt
- Naveen K Murthy - PES2201800051
- Siva Surya Babu - PES2201800475
- Roshan Daivajna - PES2201800372