Skip to content

Commit a152628

Browse files
authored
Readme
1 parent c82dbb1 commit a152628

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,49 @@
11
# Python-Compiler
22
All phases of a compiler for Python Language have been implemented using C language. The constructs 'if-else' and 'while' have been handled.
3+
4+
## Introduction
5+
The **_proj.l_** lex file and **_proj1.y_** yacc file work together to **parse** the Python code in the **_inp.py_** file and **generate tokens** to output a **symbol table** and create an **abstract syntax tree** and hence, generate the **optimised intermediate code**. This optimised intermediate code is saved in the file **_IntermediateCode.txt_** which is then accessed in the **_TargetCodeGenerator.c_** file. This file converts this optimised intermediate code to the **target code** for a hypothetic machine model which will be discussed further.
6+
7+
## Steps To Run
8+
1) Install Flex (to make lex program work)
9+
```
10+
sudo apt-get upgrade
11+
sudo apt-get install flex
12+
```
13+
2) Install Bison (to make yacc program work)
14+
```
15+
sudo apt-get upgrade
16+
sudo apt-get install bison
17+
```
18+
3) Run the lex and yacc files
19+
```
20+
lex proj.l && yacc -d -v proj1.y && gcc lex.yy.c y.tab.c -ll -lm -w
21+
```
22+
4) Run the TargetCodeGenerator.c file
23+
```
24+
gcc -o TargetCodeGenerator .\TargetCodeGenerator.c
25+
.\TargetCodeGenerator.exe
26+
```
27+
28+
## Implementation
29+
30+
### Context Free Grammar
31+
32+
### Parsing and Token Generation
33+
34+
### Symbol Table Creation
35+
36+
### Abstract Syntax Tree
37+
38+
### Intermediate Code Generation
39+
40+
### Code Optimization
41+
42+
### Error Handling
43+
44+
### Target Code Generation
45+
46+
## Snapshots of Sample Input and Output
47+
48+
## Contact
49+
For any comments or questions, please email at sakshidgoel@gmail.com / amoghrajesh1999@gmail.com / tanvipk99@gmail.com

0 commit comments

Comments
 (0)