Question: Use the following grammar in which program, var, begin, end , integer, and print are reserved words. Use photo 4 , final 2 4 .

Use the following grammar in which program, var, begin, end , integer, and print are reserved words. Use photo 4, final24.txt as the input. (needs to be tokenized)
Have your program (compiler) check the grammar of the program and display No Error
if the given grammar liked the program or issue some errors otherwise.
Have your program detect the following errors and issue a corresponding error message:
"program is expected" (if program is spelled wrong)
"var is expected" (if var is spelled wrong)
"begin is expected" (if begin is spelled wrong)
"end is expected" (if end is spelled wrong)
"integer is expected" (if integer is spelled wrong)
"print is expected" ( if print is spelled wrong )
"unknown identifier" if the variable is not defined
"; semicolon is missing" (if the grammar required a ; )
", comma is missing" (if the grammar required a ,)
". period is missing" (if the grammar required a .)
( The left parentheses is missing
) The right parentheses is missing
Output : Ready to compile or this is the list of errors
The whole program grammar consists of ONE line, and each non-terminal in the grammar will be defined over and over until it hits a terminal.
The table is provided in python:
parsing_table =[
["","","","","","","","","","","","","","","","","","","","","","","","","","","","", "programI;varDbeginSend", "","","","",""], # P
["","","","","","","","","","","","LK","LK","LK","LK","LK","LK","","","","","","","","","","","","","","","","",""], # I
["","","","","","","","","","","","LK","LK","LK","LK","LK","LK","JK","JK","JK","JK","JK","JK","JK","JK","JK","JK","","","","","","",""], # K
["","","","","","","","","","","","A:T;","A:T;","A:T;","A:T;","A:T;","A:T;","","","","","","","","","","","","","","","",""], # D
["","","","","","","","","","","","VA","VA","VA","VA","VA","VA","","","","","","","","","","","","","","","",""], # A
["","","","","","","","","","","", "I,", "I,", "I,", "I,", "I,", "I,", "","","","","","","","","","","","","","","",""], # V
["","","","","","","","","","","","","","","","","","","","","","","","","","","","","","","", "integer", ""], # T
["","","","","","","","","","","","BU","BU","BU","BU","BU","BU","","","","","","","","","","","","","","","","","BU"], # S
["","","","","","","","","","","","S","S","S","S","S","S","","","","","","","","","","","","","","","","","S"], # U
["","","","","","","","","","","","R","R","R","R","R","R","","","","","","","","","","","","","","","","","W"], # B
["","","","","","","","","","","","","","","","","","","","","","","","","",

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!