Skip to content

Latest commit

 

History

History
26 lines (22 loc) · 1.13 KB

README.md

File metadata and controls

26 lines (22 loc) · 1.13 KB

Compiler_Design

Overview

This repository contains the source code of the programs done in our lab using Lex and Yacc.
Lexical analysers (.l) files are used to recognise the tokens encountered in a program.
Yacc (.y) files are used to design custom grammars for one's own compiler.

Features

Lexical analysis using Lex
Syntactic analysis and parsing using Yacc
c files & txt files for code input
There are a lot of garbage files which are a result of .y & .l file evaluation

Usage

It's better to work on a UNIX based OS (Ubuntu / Redhat / CentOS)
Make sure you have Flex (Lex) & Bison (YACC) installed on your system

How to run lex files (.l files)

Run the following commands in order

lex <file_name.l>
gcc lex.yy.c -ll -o <custom_file_name>
./<custom_file_name> < input_file > output_file

How to run yacc files (.y files)

Run the following commands in order

yacc -dv <file_name.y>
gcc y.tab.c -ll -o <custom_file_name>
./<custom_file_name> < input_file > output_file

Feel free to submit a PR if you come across any issues.