Skip to content

roshan-d21/rust-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rust-Compiler

Introduction

Problem Statement: Build a basic Rust compiler using Lex and Yacc

The compiler performs the following tasks:

  1. Lexical Analysis
  2. Symbol Table Generation
  3. Syntax Analysis
  4. Semantic Analysis
  5. Error Detection
  6. Intermediate Code Generation
  7. Code Optimization

Installing Dependencies

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

Usage

For Phase 1 of the compiler (Lexical and Syntactical Analysis)

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

For Phase 2 of the compiler (ICG and Code Optimization)

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

Team Members

  • Naveen K Murthy - PES2201800051
  • Siva Surya Babu - PES2201800475
  • Roshan Daivajna - PES2201800372