Question: We've seen VM Code and how that can be translated to Assembly and Machine code, but these languages are represented as basic sequences of instructions
We've seen VM Code and how that can be translated to Assembly and Machine code, but these languages are represented as basic sequences of instructions how do we handle the nested and varied structures of highlevel programming languages?
Using your preferred programming language Python C or Java implement the CompilerParser as described below.
This practical assignment follows a similar approach to the NandTetris Compilation Engine.
Template files are provided for each of these programming languages.
Download the Python version HERE Download HERE.
Download the Java version HERE Download HERE.
Download the C version HERE Download HERE.
You will need to complete the methods provided in the CompilerParser class.
The provided ParseTree & Token classes should not be modified.
Only submit files for programming language.
Getting Started
Start by reviewing chapter of the textbook.
Each of the methods listed below needs to apply the corresponding set of grammar rules to the series of tokens given.
For each set of these grammar rules:
A new parse tree is created.
The tokens are processed by
Tokens matching the grammar rule are added to a ParseTree for that rule.
If the rules are broken ie the sequence of tokens does not match the rules a ParseException should be thrownraised
Otherwise the ParseTree data structure is returned.
Some of the sets grammar rules require other sets of grammar rules.
For example, the whileStatement rule requires the rules for expression and statements.
These rule sets should be applied recursively.
A ParseTree data structure is returned
Tokens
Each token has a type and corresponding value.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
