Question: Write a compiler for a simple language based off Example 3.1. The Python PLY library will be used to implement the lexical and parser for

Write a compiler for a simple language based off Example 3.1.

Write a compiler for a simple language based off Example 3.1. The

The Python PLY library will be used to implement the lexical and parser for the language. A starter compiler that implements the BNF listed in Example 3.1 is attached below. What you need to do is:

Python PLY library will be used to implement the lexical and parser

for the language. A starter compiler that implements the BNF listed in

Example 3.1 is attached below. What you need to do is: Show

your output afterwards. EXAMPLE 3.1 A Grammar for a Small Language begin

Show your output afterwards.

EXAMPLE 3.1 A Grammar for a Small Language begin end | ; = + | - | 1. Downloading the start code and make sure you can run successfully. 2. Adding necessary rule(s) and corresponding code to support a print statement as follows: print w, where w is an identifier or a numeric literal. 3. Adding necessary rule(s) and corresponding code to support a repeat statement as follows: repeat n begin stmt-list end, where n is a numeric literal. The compiler should be able to successfully parse and generate c-like code as follows: begin x = 10; Y = 20; repeat 100 begin a = x + 10; b = y + x + 100; print a; end print x; end Generated code (generating proper indentation is not required) int main() { x = 10; = 20; for (int i = 0; i

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!