[SOLVED] 代写 XML compiler 20191030 Assignment 3 codegen: Computer Systems 20007081 Combined

30 $

File Name: 代写_XML_compiler_20191030_Assignment_3__codegen:_Computer_Systems_20007081_Combined.zip
File Size: 810.12 KB

SKU: 7404738630 Category: Tags: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

Or Upload Your Assignment Here:


20191030 Assignment 3codegen: Computer Systems 20007081 Combined
Assignment 3codegen
Description
You must complete the implementation of the jcodegen program in the file codegen.cpp.
The program reads an XML representation of an abstract syntax tree of a Jack class from standard input and writes a Hack Virtual Machine VM code implementation of the class to standard output. It uses the functions described in abstractsyntaxtree.h to traverse an abstract syntax tree and the functions
in iobuffer.h to write VM code to standard output. The main function is responsible for calling
the astparsexml function and passing the result to the jackcodegen function. The astparsexml function is responsible for reading an XML representation of the abstract syntax tree from standard input. All output must be written using the writetooutput function described in iobuffer.h.Compiling and Running codegen
When the Makefile attempts to compile the program codegen, it will use the file codegen.cpp, any other .cpp files it can find whose names start codegen. For example, if we have our own class abc that we want to use when implementing codegen, we would name the extra files, codegenabc.cpp
and codegenabc.h.
The program can be compiled using the command:
make codegen
The suite of provided tests can be run using the command:
make testcodegen
The test scripts do not show the program outputs, just passed or failed, but they do show you the commands being used to run each test. You can copypaste these commands if you want to run a particular test yourself and see all of the output.
Note: Do not modify the provided Makefile or the subdirectories bin, includes or lib. These will be replaced during testing by the web submission system.
jackcodegen
The final stage of writing a compiler is to generate a new representation of the program in the target language using the information discovered during parsing. The purpose of the jackcodegen function is to take the output of the jackparser function and translate it into the equivalent VM language. Since Chapter 11 gave many translation examples and you have example outputs, we dont provide specific guidelines on how to develop the code generation features of the jackcodegen function.
Since you need to be able to walk over every node of an abstract syntax tree representing a Jack class, we have provided a skeleton of the tree walking functions required in the codegen.cpp file. This should save you a lot of typing. However, you do not need to follow this structure if you do not want to.
https:myuni.adelaide.edu.aucourses44936pagesassignment37Ccodegen 12

20191030 Assignment 3codegen: Computer Systems 20007081 Combined
We strongly suggest that you test your function with small examples first so that you can independently test the functionality you are implementing. You can also construct small example Jack programs and see what VM code the JackCompiler produces. This is a good way to work out how best to generate code for specific cases. In the example outputs you have been given, the files with names
ending .Cvm contain VM code.
There is one part of the code generation which is not well defined by the Jack language, namely expression evaluation. For the purposes of this assignment we will assume that there is no operator precedence and that all expressions are evaluated left to right.
Notes:
Do not modify the main function in codegen.cpp.
All output must be written using the writetooutput function in includesiobuffer.h.
All output must be written with one VM command per line.
VM labels are local to their function, you can reuse the same name in more than one function.
Use the label names WHILEEXP and WHILEEND for while loops. Append a unique number for each while loop in a function starting from 0. Restart the count in each new VM function.
Use the label names IFTRUE, IFFALSE and IFEND for if statements. Append a unique number for each if statement in a function starting from 0. Restart the count in each new VM function.
String literals must be created using the String.new constructor and then adding each character using the String.appendChar method one at a time.
Integer constant values should all be in the range 0 to 32,767. However, the astint node will accept any value in the range 32,768 to 32,767. Where a negative value is found, the absolute integer value must be pushed onto the stack and followed by a neg command. In the special case of , 32,768, the integer constant 16,384 must be pushed onto the stack twice followed by an add command.
https:myuni.adelaide.edu.aucourses44936pagesassignment37Ccodegen 22

Reviews

There are no reviews yet.

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

Shopping Cart
[SOLVED] 代写 XML compiler 20191030 Assignment 3 codegen: Computer Systems 20007081 Combined
30 $