[Solved] MPP Assignment 2 AST Generator

$25

File Name: MPP__Assignment_2__AST_Generator.zip
File Size: 301.44 KB

SKU: [Solved] MPP – Assignment 2 – AST Generator Category: Tag:
5/5 - (1 vote)

Contents

1 Specification 2

2 Submission 3

3 Change Log 3

Assignment 2version 1.0

After completing this assignment, you will be able to

  • explain the stucture of parser generated by ANTLR
  • manipulate (traverse, create) on tree, which has different types of node, using Visitor
  • write a short program in Python to generate intermediate code (AST) for a valid MP program

1 Specification

A parser will check if the input is grammatically correct or not. If the input is grammatically wrong, an error message is released. This is what you did in the assignment 1. In the case the input is grammatically correct, an intermediate code is generated. This is the requirement of this assignment. As AST is selected to be the intermediate code, you are required to write an AST generator for a program written in MP. To complete this assignment, you need to watch the lecture of AST to:

  • investigate the structure of a parser generated by ANTLR
  • try to find out how to generate an AST from a parse tree.
  • investigate the AST classes defined in Python.
  • modify py to generate an AST.
  • check your code to make sure it right.

To complete this assignment, you need to:

  • download initial code (assignment2.zip) and unzip it.
  • copy your MP.g4, your solution of assignment 1, into folder src/main/mp/parser.
  • have a look at folder src/main/mp/utils in the code of assignment 2 where there are 2 files py and Visitor.py. In these two files, just only AST.py is used in this assignment while the other file will be used in the next one. AST.py defines all classes in AST which is the output of this assignment. You are NOT allowed to modify all these files.
  • modify ASTGeneration.py in folder src/main/mp/astgen to generate AST from a parse tree, i.e. the result of assignment 2, generated from ANTLR.
  • modify ASTGenSuite.py in folder src/test/ to create 100 tests in total for this assignment.

2 Submission

This assignment requires you submit your code in 3 files: MP.g4, ASTGeneration.py and ASTGenSuite.py. MP.g4 is often modified to complete this assignment but even when it is not modified, it must also be submitted.

All the testcases for this assignment are correctly grammatically correct.

You are required to submit just only 3 files MP.g4, ASTGeneration.py and ASTGenSuite.py, which must have 100 different tests. Note that you must NOT compress your files when submit them.

The website www.cse.hcmut.edu.vn/onlinejudge will be opened soon for your testing of your code but you MUST submit your three files into BKeL. The deadline of the submission is announced in BKeL.

You must complete the assignment by yourself and do not let your work seen by someone else, otherwise, you will be punished by the university rule for plagiarism.

3 Change Log

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] MPP Assignment 2 AST Generator
$25