-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathREADME
More file actions
34 lines (28 loc) · 1.03 KB
/
README
File metadata and controls
34 lines (28 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
About
=====
This is a modified version of [asankarc]'s compiler. The tasks performed by each of the files are listed as follows.
- one.py - A recursive descent parser that can parse the below grammar.
- two.py - An extension of the one.py's code which transforms
the specified expression list into postfix notation.
- three.py - A simple stack based machine that can evaluate the postfix notation and execute the postfix notations.
- four.py - An extension of the two.py's code that generates the three address code representation.
- five.py - An extension of the four.py's code that performs type checks and does a DAG optimization.
Grammar
=======
- P → D L
- D → B N ; D | B N ;
- B → int | float
- N → N , id | id
- L → S ; L | S ;
- S → id = E | E
- E → E + T | T
- T → T × F | F
- F → ( E ) | num | id
Test Files
=========
The "test" folder contains test files for each compiler (name denotes for which compiler the test is).
Ex:
```
python one.py test/1.txt
```
[asankarc]:https://github.com/asankarc/simple-compiler