Warning: foreach() argument must be of type array|object, bool given in /var/www/html/web/app/themes/studypress-core-theme/template-parts/header/mobile-offcanvas.php on line 20

Describe how productions for a grammar in extended Backus–Naur form can be translated into a set of productions for the grammar in Backus–Naur form.

This is the Backus–Naur form that describes the syntax of expressions in postfix (or reverse Polish) notation.

\(\begin{array}{c}\left\langle {{\bf{expression}}} \right\rangle {\bf{ :: = }}\left\langle {{\bf{term}}} \right\rangle {\bf{|}}\left\langle {{\bf{term}}} \right\rangle \left\langle {{\bf{term}}} \right\rangle \left\langle {{\bf{addOperator}}} \right\rangle \\{\bf{ }}\left\langle {{\bf{addOperator}}} \right\rangle {\bf{:: = + | - }}\\\left\langle {{\bf{term}}} \right\rangle {\bf{:: = }}\left\langle {{\bf{factor}}} \right\rangle {\bf{|}}\left\langle {{\bf{factor}}} \right\rangle \left\langle {{\bf{factor}}} \right\rangle \left\langle {{\bf{mulOperator}}} \right\rangle {\bf{ }}\\\left\langle {{\bf{mulOperator}}} \right\rangle {\bf{:: = *|/}}\\\left\langle {{\bf{factor}}} \right\rangle {\bf{:: = }}\left\langle {{\bf{identifier}}} \right\rangle {\bf{|}}\left\langle {{\bf{expression }}} \right\rangle \\\left\langle {{\bf{identifier}}} \right\rangle {\bf{:: = a }}\left| {{\bf{ b }}} \right|...{\bf{| z}}\end{array}\)

Short Answer

Expert verified

Translate a set of productions for the extended Backus-Naur form grammar into a set of productions for the Backus-Naur form grammar

\(\begin{array}{l}{\rm{ < A + > :: = A| < A + > A}}\\{\rm{ < X* > :: = \lambda I < X* > X}}\\{\rm{ < Q? > :: = \lambda | Q}}\\{\rm{ < }}\left( {{\rm{String}}} \right){\rm{? > :: = \lambda |String}}\end{array}\)

Step by step solution

01

About Backus-Nour form.

The Backus-Naur form is a notation for specifying a type 2 grammar.

Productions in a type 2 grammar have a single non-terminal symbol on the left.

Rather of listing all the productions separately, we can merge all those with the same non terminal symbol on the left-hand side into one statement instead of using the symbolàin a production,

The symbol:: =

All non-terminal symbols are enclosed in brackets (>), and all productions' right-hand sides are listed in the same statement, separated by bars.

02

The Backus-Naur form now includes the following extensions:

"+": denotes that the symbol to the left of it may appear once or more.

The symbol or group of symbols enclosed in parenthesis to the left of the sign "?" may appear zero or once.

"*": denotes that the sign to the left of it may appear once or more.

03

Step 3: For translating a set of productions for the grammar in extended Backus-Naur form to a set of productions for the grammar in Backus-Naur form,

Replace the use of +, * and “?”, so that rules have the same effect.

For replacing '+' sign: let us take a symbol A, so we have to replace A+.

Hence the new rule can be as:

\({\rm{ < A + > :: = A| < A + > A}}\)

For replacing ‘*’ sign: let us take a symbol X. so we have to replace X*. So; the new rule can be as:

\({\rm{ < X* > :: = \lambda I < X* > X}}\), where ‘?’ is the empty string Comment

To replace the "?" sign, let's use the letter Q. What should we use in its place?

The new regulation will be:

\({\rm{ < Q? > :: = \lambda | Q}}\)

For a string of symbols. let us assume it as the non-terminal String.

So, replace (String)? with:

\({\rm{ < }}\left( {{\rm{String}}} \right){\rm{? > :: = \lambda |String}}\)

Therefore, productions for a grammar in extended Backus–Naur form can be describe as above.

Unlock Step-by-Step Solutions & Ace Your Exams!

  • Full Textbook Solutions

    Get detailed explanations and key concepts

  • Unlimited Al creation

    Al flashcards, explanations, exams and more...

  • Ads-free access

    To over 500 millions flashcards

  • Money-back guarantee

    We refund you if you fail your exam.

Over 30 million students worldwide already upgrade their learning with Vaia!

One App. One Place for Learning.

All the tools & learning materials you need for study success - in one app.

Get started for free

Most popular questions from this chapter

Describe the set of strings defined by each of these sets of productions in EBNF.

\(\begin{array}{c}\left( {\bf{a}} \right){\bf{string :: = L + D?L + }}\\{\bf{L :: = a }}\left| {{\bf{ b }}} \right|{\bf{ c }}\\{\bf{D :: = 0 | 1}}\\\left( {\bf{b}} \right){\bf{string :: = signD + |D + }}\\{\bf{sign :: = + | - }}\\{\bf{D :: = 0 | 1|2|3|4|5|6|7|8|9}}\\\left( {\bf{c}} \right){\bf{string :: = L*}}\left( {{\bf{D + }}} \right){\bf{?L* }}\\{\bf{L :: = x |y }}\\{\bf{D :: = 0 | 1}}\end{array}\)

Determine whether the string 11101 is in each of these sets.

a){0,1}* b){1}*{0}*{1}*

c){11} {0}*{01 d){11}*{01}*

e){111}*{0}*{1} f){11,0} {00,101}

Suppose that S, I and O are finite sets such that \(\left| S \right| = n, \left| I \right| = k\), and \(\left| O \right| = m\).

\(a)\)How many different finite-state machines (Mealy machines) \(M = \left( {S,I,O,f,g,{s_0}} \right)\) can be constructed, where the starting state \({s_0}\) can be arbitrarily chosen?

\({\bf{b)}}\)How many different Moore machines \(M = \left( {S,I,O,f,g,{s_0}} \right)\) can be constructed, where the starting state \({s_0}\) can be arbitrarily chosen?

What is an unsolvable decision problem? Give an example of such a problem.

Describe the set of strings defined by each of these sets of productions in EBNF.

\(\begin{array}{c}\left( {\bf{a}} \right){\bf{string :: = L + D?L + }}\\{\bf{L :: = a }}\left| {{\bf{ b }}} \right|{\bf{ c }}\\{\bf{D :: = 0 | 1}}\\\left( {\bf{b}} \right){\bf{string :: = signD + |D + }}\\{\bf{sign :: = + | - }}\\{\bf{D :: = 0 | 1|2|3|4|5|6|7|8|9}}\\\left( {\bf{c}} \right){\bf{string :: = L*}}\left( {{\bf{D + }}} \right){\bf{?L* }}\\{\bf{L :: = x |y }}\\{\bf{D :: = 0 | 1}}\end{array}\)

See all solutions

Recommended explanations on Math Textbooks

View all explanations

What do you think about this solution?

We value your feedback to improve our textbook solutions.

Study anywhere. Anytime. Across all devices.

Sign-up for free