Mini Compiler for Python 3.x with support for FOR,WHILE constructs and other basic syntax.
Pictures present in the report.
We know that there are too many folders in the repo. Go to FINAL and run chmod +x work.sh
. Then simply run work.sh
and you will get the outputs.
The parser file is parser_file_with_values.y
and the lexer file is lex_file.l
The tests file are in Code_Optimization/tests
folder of the FINAL
folder.
On the quads (quads.tsv
) generated in the Code_Optimization/non_optimized
folder, you can run the python optimization scripts. Just go through the code of each of the optimization scipts, you will understand!
- Lexical Phase
- Syntactic Phase
- Semantic Phase
- ICG generation with TAC in quads format
- Code Optimization
- Common Sub-Expression Elimination
- Dead Code Elimination
- Constant Folding and Propagation
- Loop Invariant Code Movement
- https://github.com/sharanyavenkat25/CD-Project : The Grammar for the language
- https://github.com/craterkamath/Python_Mini_Compiler : Amazing way to get the indentation!
- https://github.com/anagha1999/CD-Project : Actions and Code Optimization part
- The grammar is somewhat not right because it cannot handle multiple loops (but it can handle nested loops!).
- All pathways haven't been tested, some issues might crop up: would love to hear them!
Feel free to use the code (as long as you are not caught by your teachers!). I don't think I can stop you from using a public repo either ways!