Languages - Leftmost Derivations

Soldato
Joined
7 Apr 2004
Posts
4,212
Hi,

I have an exam coming up soon, and im having problems understanding how to do left/rightmost derivations from my notes for some slightly complex grammars.

I can do it fine for simple grammars and strings e.g

Grammer:
S -> aAs | a
A -> AbA | SS | ba

and so i can derive: "S -> aAs" so there are no more non-terminals. This exam question is slighly more complex though.

gram.jpg


Please could someone point me in the right direction for doing a leftmost derivation of that?

Thanks for any help
 
Replace the leftmost non-terminal first...

I guessed that much... its replacing what with what which is confusing me.

So IF is the first leftmost non-terminal in the string, im not sure what i replace that with because in the examples ive seen if i want to replace X then theres a grammar rule X -> Y | Z... in this example there is nothing for IF -> X and hence I really have no idea what im doing :confused:
 
Back
Top Bottom