Question: Write an interpreter which uses the top - down recursive - descent method to parse and evaluate a very simple programming language. The tiny language's
Write an interpreter which uses the topdown recursivedescent method to parse and evaluate a very simple programming language. The tiny language's grammar is given below.
:: empty
:: id ; print ;
::
::
:: id intnum
The interpreter should be written in Python. It takes one input file sampletiny which is a text file consisting of the statements of the above grammar. The input file name sample.tiny is given from the command line. The interpreter parserxxxxxxxpy reads the program file sample.tiny, checks the syntax and outputs the result if the program is legitimate; otherwise, the interpreter prints "Syntax Errors".
Below are some test examples in sample.tiny:
print ;
s ;
t ;
print s t ;
print s t s t ;
Please issue python parserxxxxxxxpy sample.tiny on the spirit machine to test your Python program before you turnin it Please use if namemain: in your code
Sample running results:
Command Line: python parserxxxxxxxpy sample.tiny
Output:
Print ;
s ;
t ;
print s t ;
Print s t s t ;
There are answers to this question on chegg but they didn't work for me
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
