Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Consider the following grammar rule: N rightarrow a((Cb) * B|Ac|Ab)b, where N, A

ID: 3814913 • Letter: C

Question

Consider the following grammar rule: N rightarrow a((Cb) * B|Ac|Ab)b, where N, A, B, C are nonterminals, and a, b, c are terminals. Note that (Cb) * could be empty and this creates another case and A, B could be empty also. Analyzing all possible cases for the switch statement when building a recursive descent parser for a grammar which includes this grammar rule. b) Write a piece of pseudo-code for the procedure parse N(), which parses N, the non-terminal on the left-side of the following grammar rule.

Explanation / Answer

let us find the language first

N=a or

N=c or

N=bb

so this is the language which may be produced by the given grammer

so the cases for swithc statement can be

switch(a)

switch(bb)

switch(c)

b)

if C=empty && B=empty

then

N=a(fpr first grammer)

if A= empty /null

then N=c

if A=empty/null

then N=bb

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote