0

EBNF

<A> ::= <B><C> '('[<D>{,<D>}]')';

When I solve the problem, it comes out like this:

BNF

<A>::=<B><C>(); |<B><C> (<D>|<A><D>);

Is the answer correct?

Ash
  • 1
  • 1
  • Your EBNF doesn't look correct. EBNF generally drops the angle brackets around non-terminals because terminal symbols are enclosed in quotes. Also, you don't enclose the one instance of a comma in quotes. In some EBNF, comma is the concatenation operator. If you intended for it to be a concatenation, then you don't apply it consistently in the rest of the rule. I suspect it a literal. So, shouldn't your EBNF rule be `A ::= B C '(' [ D { ',' D } ] ')' ;`? We can't answer your question otherwise. – kaby76 Oct 10 '21 at 03:00

1 Answers1

0

It contains instructions for each production that needs to be converted:

From EBNF to BNF

For building parsers (especially bottom-up) a BNF grammar is often better, than EBNF. But it's easy to convert an EBNF Grammar to BNF:

  • Convert every repetition { E } to a fresh non-terminal X and add X =

    $\epsilon$ | X E. 
    
  • Convert every option [ E ] to a fresh non-terminal X and add

    X = $\epsilon$ | E. (We can convert X = A [ E ] B. to X = A
    E B | A B.) 
    
  • Convert every group ( E ) to a fresh non-terminal X and add X = E.

  • We can even do away with alternatives by having several productions with the same non-terminal.

    X = E | E'. becomes X = E. X
    = E'.
    

Refer this links:

Vijay Kumavat
  • 621
  • 1
  • 10
  • 13