Question: 1 ) Below is the parser written in class for the grammar S aA | ; A bS: ( setf program ' ( ) )
Below is the parser written in class for the grammar S aA; A bS:
setf program
defun gettk car program
defun accepttk setf program cdr program
defun S
if null program
Parsing successful"
if eq gettka
progn accepttkA
unexpected token"
defun A
if null program
Program ended unexpectedly"
if eq gettkb
progn accepttkS
unexpected token"
Modify the above parser for the following grammar, and demonstrate using nontrivial strings that the parser correctly parses valid and invalid strings allowed by the grammar:
S bA c
A cS d
Note #: By correctly, it is meant as expected by flagging errors for invalid strings and displaying "success" for valid strings.
Note #: By nontrivial string, it is meant a string other than a trivial string, examples of trivial strings are cb d and e
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
