Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started