Starting from:

$29.99

CSE-PPL Assignment 4 -Code Generation Solution



Contents
1 Specification 2
2 Submissions 2
4 Change Log 3


After completing this assignment, you will be able to
• explain the mechanism of some structures in a programming language.
• use Python to implement a code generation phase for a stack-based machine like JVM.
• create a complete compiler for JVM.
1 Specification
In this assignment, you are required to write a code generation checker for a program written in MP. The code generation will generate Jasmin code from AST created from assignment 2. The Jasmin code then is transfered to Java bytecode which must be run correctly in a Java Virtual Machine (JVM). To complete this assignment, you need to:
• read carefully the specification of BKOOL language
• Download initial code assignment4.zip, unzip it, read README.txt and follow the instruction to test it.
• If you would like to make your testcases in BKOOL language, copy your BKOOL.g4 to folder main/bkool/parser and your ASTGeneration.py to folder main/bkool/astgen. Otherwise, you can build your testcases in AST like test 502 and 503.
• Modify main/bkool/codegen/CodeGenerator.py and main/bkool/codegen/Emitter.py to implement this assignment.
• Modify test/CodeGenSuite.py to create 100 testcases to test your code. Note that the entry method (i.e. main) must be in the class whose name is "BKoolClass".
All testcases of this assignment is grammatically and semantically correct.
2 Submissions
As this assignment requires big resource to run so the pre-test cannot be set up as the previous assignments. You must check yourself your work before submission. The operating system when cheking your submission is Linux.
• You must submit three files: CodeGenerator.py, Emitter.py and CodeGenSuite.py.
• You must complete the assignment by yourself and do not let your work seen by someone else.
• You just submit your code in your allocated account.
4 Change Log

More products