Given the following grammar and the right sentential form, draw a parse tree and then specify and write the phrases, simple phrase(s), and the handle.
Grammar: S → aAb | bBA A →
ab | aAB
B → aB | b
Sentential form: aaababb
Q.Given the following grammar and the right sentential form, draw a parse tree and then specify and write the phrases, simple phrase(s), and the handle.
Grammar: S → aAb | bBA A →
ab | aAB
B → aB | b
Sentential form: aaababb
Answer: a. aaAbb Parse Tree: S / | \ a A b /|\ a A B | b Handles: b, aAB Phrases: aaAbb, aaABb, aAb Simple Phrase: b b. bBab Parse Tree: S / | \ b B A / \ a b Handles: ab Phrases: bBab, bBA Simple Phrase: ab c. aaAbBb aaAbBb --> aSBb --> aSBB --> x or aaAbBb--> aaAbBB --> aSBB --> x Therefore the last string can not be derived from the given grammar.
Get Answers For Free
Most questions answered within 1 hours.