tags:

views:

226

answers:

1

I have a homework problem which I could use some help on. I need to convert the following EBNF statement to BNF

<S> -> <A>{b<A>}
<A> -> a[b]<A>

This is what I have come up with so far;

<S> -> <A> | <A><S> | b<A>
<A> -> a<A> | ab<A>

It doesn't feel right, mainly because it's a WAG. The example in my book (Concepts of Programming Languages, Sebesta) is not helping me at all. So if anyone has any insight, it would be greatly appreciated. Thanks!

A: 

The first grammar seems buggy, or at least needlessly messy. But take a look here for a mechanical way to convert EBNF to BNF:

http://lamp.epfl.ch/teaching/archive/compilation-ssc/2000/part4/parsing/node3.html

Andre Artus