https://github.com/sahasourav17/compiler-lab
https://github.com/sahasourav17/compiler-lab
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/sahasourav17/compiler-lab
- Owner: sahasourav17
- Created: 2022-08-16T19:59:46.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-11-11T15:50:19.000Z (almost 3 years ago)
- Last Synced: 2025-01-07T21:46:57.885Z (9 months ago)
- Language: C
- Size: 153 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Compiler-Lab
## Install Flex and Bison on Linux:
### Step-1: Run the following commands in your terminal
* sudo apt update
* sudo apt-get install bison flex### Step-2: Commands to compile lex file:
* lex filename.l (in my case it is test.l)
* gcc lex.yy.c
* ./a.out## Problem Statement
#### Write a program using flex and bison that takes input and divide the lexemes of that input into following tokens:
1. **Keywords:** if,then,also,int,char,main,str,return,struct,class...
2. **Relational Operators:** >,<,>=,<=,==
3. **Arithmatic Operators:** +,-,*,/,++,--
4. **Assignment Operators:** =,+=,*=,/=
5. **Logical Operators:** &&,||,!,!=
6. **Valid Numbers:** 0,1,2,3,12.43,0.12 ....
7. **Valid Identifiers:** length,len234, my_name12, temp23name ...
8. **Function Name:** main(),foo(),myFunc() ...
9. **Other Symbols:** { ,} ,( ,) ,[ ,] ,; ,' ,' , ", " ...
10. **String**: "CUET","Sourav","cse", ...### Note:
- I have taken input from in.txt file.
- You can change input by changing the contents of the input file.## Commands:
```bash
git clone https://github.com/sahasourav17/Compiler-Lab.git
cd Compiler-Lab/Lex_project/
```
After that follow **Step-2**