Give an unambiguous BNF grammar do not use an extended BNF f

Give an unambiguous BNF grammar (do not use an extended BNF) for {0^i 1^i | i greaterthanorequalto 0}. Note that, the expression 0^i denotes i repetitions of the symbol 0. For example, 0^31^3 denotes 000111. L = {01,0011,000111, ...}.

Solution

BNF is in the form
<Non-Terminal> ::= Replacement

*A Terminal is any symbol that cannot be replaced or we can also say a terminal is any symbol that does not appear on the left-hand side.

*replacement consist of one or more number of symbols(both terminal and non-terminals are considered symbol) and more sequences are separated by the vertical bar \"|\", indicating a choice,

For the given question the answer would be as given below:

<S> ::= \"0\" <S> \"1\" | \"\"

we can produce String 01 by:
S => 0S1 => 01
Similarly we can produce String 0011 by:
S => 0S1 => 00S11 => 0011

We can similarly produce all words in the language L.

 Give an unambiguous BNF grammar (do not use an extended BNF) for {0^i 1^i | i greaterthanorequalto 0}. Note that, the expression 0^i denotes i repetitions of t

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site