Question: Fall 2 0 2 4 CIS 5 2 4 Project ( Group Project ) ( Due Oct 2 0 ) In this project you are

Fall 2024 CIS 524 Project (Group Project)
(Due Oct 20)
In this project you are asked to write an interpreter which uses the top-down recursive-descent
method to parse and evaluate a very simple programming language. The tiny language's grammar
is given below.
::={}
::= let in () end ;
::={}
::= id : = ;
::= int | real
::={+|-}|
if then else
::={*|/}
::=()| id | number |( id )
::=|
=|
>|
>=|
==|
>
::= id | intnum
The interpreter (parser_xxxxxxx.py where xxxxxxx is your CSU ID) should be written in Python
with similar structures to the c++ version in the Blackboard. It takes one input file (sample.tiny)
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 parser_xxxxxxx.py reads the program
file sample.tiny, checks the syntax and outputs the result if the program is legitimate; otherwise,
the interpreter prints "Error".
Below is a test example:
let x : int =7 ;
y : real =3.0;
in
real (( real ( x )+ y )*( real ( x )- y ))
end ;
let x =8 ; in ( x + y ) end ;
Your program will output
40.0
Error
For another example,
let x : int =5 ;
in
int ( x + x * x )
end ;
let r : real =10.0 ;
pi : real =3.1416 ;
in
real ( pi * r * r )
end ;
let a : int =3 ;
b : real =0.5 ;
c : real = b * b ;
in
real ( if a >5 then b +1.1 else c )
end ;
Your program should display
30
314.16
0.25
Submit via Blackboard:
Upload your parser_xxxxxxx.py file to the project submission area on Blackboard.
Make sure the file is correctly named using your CSU ID.
No other files should be submitted. ```
let x : int =5 ;
in
int ( x + x * x )
end ;
let r : real =10.0 ;
pi : real =3.1416;
in
real ( pi * r * r )
end ;
let a : int =3 ;
b : real =0.5 ;
c : real = b * b ;
in
real ( if a >5 then b +1.1 else c )
end ;
```
Your program should display
\[
\begin{array}{l}
30\\
314.16\\
0.25
\end{array}
\]
Submit via Blackboard:
- Upload your parser_xxxxxxx.py file to the project submission area on Blackboard.
- Make sure the file is correctly named using your CSU ID.
- No other files should be submitted.
Fall 2 0 2 4 CIS 5 2 4 Project ( Group Project )

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 Programming Questions!