Converting EBNF To BNF


Answer :

See this page. 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 = ε | X E.


  • Convert every option [ E ] to a fresh non-terminal X and add


    X = ε | 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'.






Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable