0
<A> ::= <B> x {<B> <D>} y <B>
<B> ::= <C> (w|z) <C> <D>
<C> := m [n] <D> <E> 
<D> := q | null
<E> := p | null

How would you convert this EBNF into BNF?

1 Answers1

1

Different people use a different syntax for EBNF, and I'm not sure which one you are using. Your grammar in EBNF (ISO/IEC 14977: 1996(E)) would look like this:

A = B, "x", {B, D}, "y", B;
B = C, ("w" | "z"), C, D;
C = "m", ["n"], D, E; 
D = ["q"];
E = ["p"];

Assuming you use null for the empty string. Notice that this could be further simplified.

Some productions must be added to convert this to BNF:

  • { expr } can be replaced by inserting a production P := empty | expr P where empty represents the empty string.

  • [ expr ] can be replaced by inserting P := empty | expr.

  • Any expression ( expr ) can be replaced by adding a new production P := expr.

So something like this:

A -> B x F y B
F -> empty | B D F
B -> C G C D
G -> w | z
C -> m H D E
H -> empty | n
D -> q | empty
E -> p | empty

Again, assuming that with null you mean the empty string.

Aleph
  • 1,209
  • 10
  • 19